Skip to content

fix(cli): Handle corrupt taskless.json manifest during init#15

Merged
thecodedrift merged 3 commits intomainfrom
fix/cli-manifest-json-parse
Apr 8, 2026
Merged

fix(cli): Handle corrupt taskless.json manifest during init#15
thecodedrift merged 3 commits intomainfrom
fix/cli-manifest-json-parse

Conversation

@thecodedrift
Copy link
Copy Markdown
Member

Summary

  • readManifest() in migrate.ts only caught ENOENT errors when reading .taskless/taskless.json, so a corrupt or unparseable manifest would crash init with a raw SyntaxError (e.g. "unexpected token *")
  • Now catches SyntaxError and treats it the same as a missing file — resets to version 0 so migrations re-run and rewrite the manifest correctly

Test plan

  • Run taskless init with a valid .taskless/taskless.json — should work as before
  • Run taskless init with a corrupt .taskless/taskless.json (e.g. echo "***" > .taskless/taskless.json) — should recover gracefully instead of crashing

🤖 Generated with Claude Code

readManifest() only caught ENOENT errors, so a corrupt/unparseable
taskless.json would crash init with a raw SyntaxError (e.g. "unexpected
token *"). Now treats SyntaxError the same as a missing file — resets to
version 0 so migrations re-run and rewrite the manifest.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 7, 2026 07:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves CLI init/migration resilience by treating a corrupt/unparseable .taskless/taskless.json manifest the same as a missing manifest, allowing migrations to re-run and regenerate a valid manifest instead of crashing.

Changes:

  • Catch SyntaxError while reading/parsing the manifest and default to { version: 0 }.
  • Preserve existing behavior for ENOENT (missing manifest) and rethrow all other errors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

thecodedrift and others added 2 commits April 7, 2026 00:54
Covers the case where .taskless/taskless.json contains invalid JSON,
verifying that ensureTasklessDirectory recovers gracefully.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The dist is a .js file relying on "type": "module" for ESM resolution.
On older Node versions or when the package.json resolution chain is
incomplete, Node falls back to CJS and chokes on `import *` syntax.
Adding explicit "module" and "exports" fields improves ESM discovery.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@thecodedrift thecodedrift merged commit f93e9f0 into main Apr 8, 2026
1 check passed
@thecodedrift thecodedrift deleted the fix/cli-manifest-json-parse branch April 8, 2026 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants