Skip to content

Refuse a malformed --github/--jira issue id as invalid_value (exit 2) - #96

Merged
baldurpan merged 2 commits into
mainfrom
85-an-invalid-github-jira-issue-id-exits-1-as
Oct 2, 2026
Merged

baldurpan merged 2 commits into
mainfrom
85-an-invalid-github-jira-issue-id-exits-1-as

Conversation

@baldurpan

Copy link
Copy Markdown
Contributor

Closes #85

worktree branch --github abc (or a malformed --jira key) was refused with a plain Error. That made the CLI exit 1, and --json reported failed. The documented contract (the README's agent-mode error table, the skill, the branch docs page) gives a refused value invalid_value with exit 2. A coordinator that branches on the exit code therefore treated a typo in an issue id as a runtime failure worth retrying.

  • src/integrations/github.ts (fetchGitHubIssue, assignGitHubIssue) and src/integrations/jira.ts (getIssueKey) now throw the existing InvalidValueError for a malformed id. The message text is unchanged. A well-formed id that doesn't exist, and a failed fetch, still throw a plain Error and exit 1.
  • The integration tests for all three sites now also assert code: "invalid_value", oclif: { exit: 2 }. A command-level test in branch.test.ts runs --github abc --json and a malformed --jira key through the real validation and asserts the invalid_value document, exit 2 and no worktree created. With the integration code reverted to main, that test fails with code: 'failed'.
  • The branch docs page's invalid_value row now lists a malformed --github/--jira issue id among its examples.
  • Adds a patch changeset.

Known and left out of scope: branch.ts converts --github with Number(...), so --github abc is refused as GitHub: Invalid issue id "NaN". The code and exit are now right; only the quoted value is unhelpful.

…alue

A malformed GitHub issue id or Jira key was thrown as a plain Error, so
the CLI exited 1 and --json reported "failed" — a coordinator branching
on the exit code read a typo as a runtime failure worth retrying. Throw
InvalidValueError instead, so it exits 2 with "invalid_value" as the
documented contract says. A missing issue or a failed lookup still
exits 1.

Closes #85

@craig-o-curtis craig-o-curtis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ya, sure, you betcha. This one's a nice little fix and it's good to go.

Had a look at all of it:

  • The three spots (fetchGitHubIssue, assignGitHubIssue, Jira's getIssueKey) now throw the InvalidValueError that's already in prompt.ts, which carries code: "invalid_value" and oclif.exit: 2, so BaseCommand.catch does the right thing without any new plumbing. Messages are the same as before.
  • A well-formed id that isn't there, or a lookup that falls over, still exits 1. That's the right split, since a typo isn't something a coordinator ought to be retrying.
  • The tests check the code and the exit at each of the three sites, and the branch.test.ts case runs the real validation end to end and makes sure no worktree got made. Good that it restores the stubs first so it isn't just testing a mock.
  • The README and skill tables already described invalid_value in general terms, so only the branch page needed the extra example, and it got it. patch changeset is there, and ci and changeset are green.

One small thing for another day, and you already called it out yourself: --github abc comes back as Invalid issue id "NaN", which is a bit of a head-scratcher for whoever typed it. Might be worth a wee follow-up issue so it doesn't get lost.

I went by the diff and the green CI on this head; didn't run the suite on my own machine.

Pretty good deal. Thanks for sorting it out!

@baldurpan
baldurpan enabled auto-merge (squash) October 2, 2026 21:49
@baldurpan
baldurpan merged commit 81bbfe4 into main Oct 2, 2026
2 checks passed
@baldurpan
baldurpan deleted the 85-an-invalid-github-jira-issue-id-exits-1-as branch October 2, 2026 21:49
baldurpan added a commit that referenced this pull request Oct 2, 2026
…ve-agent-as

No conflicts and no overlap with this branch. Corrects verify.md's test-count snapshot in passing.
@baldurpan baldurpan mentioned this pull request Oct 4, 2026
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.

An invalid --github/--jira issue id exits 1 as "failed" instead of 2 as "invalid_value"

2 participants