Skip to content

fix(cli)!: exit 1 for runtime failures reported through this.error [RED-1274] [ship] - #1583

Merged
sorccu merged 1 commit into
mainfrom
simo/red-1274-runtime-error-exit-code
Oct 26, 2026
Merged

sorccu merged 1 commit into
mainfrom
simo/red-1274-runtime-error-exit-code

Conversation

@sorccu

@sorccu sorccu commented Oct 26, 2026

Copy link
Copy Markdown
Member

Linear: RED-1274

oclif's this.error() exits 2 unless given an exit code, the same code as a usage error. Five runtime failures used it without one, so a script or agent could not tell "called wrongly" from "failed". They now pass { exit: 1 }, and exit 2 is left for invalid input.

The 27 other this.error() calls reject invalid flag or argument values (an unknown --target, --limit out of range, conflicting flags) and keep exit 2.

  • login: cancelling the account prompt raised a CLIError inside login's try. The catch classified it as login_failed and rethrew it unchanged, so it exited 2.
  • switch: its cancel already exited 1, because a catch rewraps it as a plain Error. It now passes the exit code itself, so the convention doesn't depend on that catch. No behaviour change.
  • docs/output-contract.md: the exit-code table now says 2 is for usage errors and 1 includes failures reported only on stderr. A note says that runtime failures use this.error(msg, { exit: 1 }). The skill (skill.md, synced to skills/checkly/SKILL.md) drops "or another error reported only on stderr" from exit 2.

Breaking changes (for the v10 release notes)

These now exit 1 instead of 2:

  • checkly account plan <key> with a key that is not in the plan
  • cancelling the account prompt of checkly login
  • checkly skills <action> when the bundled action file cannot be read
  • checkly skills install when the skill file cannot be read or written

Testing

  • Unit tests assert oclif.exit for each case. All four new assertions fail without the fix.
  • e2e/__tests__/account-plan.spec.ts now expects 1. It passes locally against production.
  • The full unit suite passes.

🤖 Generated with Claude Code

…ED-1274]

oclif's this.error() exits 2 unless given an exit code, the same code as a
usage error. Five runtime failures used it bare: an unknown entitlement key
in `account plan`, a cancelled account prompt in `login`, an unreadable
action file in `skills`, and a failed skill-file read or write in
`skills install`. They now exit 1, so exit 2 means only invalid input.

switch's cancel already exited 1 through its rewrapping catch; it now passes
the exit code itself, which changes nothing.

BREAKING CHANGE: the failures above exit 1 instead of 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sorccu
sorccu force-pushed the simo/red-1274-runtime-error-exit-code branch from ba337b5 to 09d2dad Compare October 26, 2026 18:31
@sorccu sorccu changed the title fix(cli)!: exit 1 for runtime failures reported through this.error [RED-1274] fix(cli)!: exit 1 for runtime failures reported through this.error [RED-1274] [ship] Oct 26, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Auto-approved: ship/show PR from a same-repo branch.

@sorccu
sorccu merged commit 16bb6c6 into main Oct 26, 2026
16 checks passed
@sorccu
sorccu deleted the simo/red-1274-runtime-error-exit-code branch October 26, 2026 18:41
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.

1 participant