Skip to content

Standardize exit codes across all CLI commands #392

@betegon

Description

@betegon

Context

PR review comment from @AustinBYK: the exit code pattern used by sentry init is great and should be spread across the entire CLI, with documentation on the docs site.

Current state

  • Only sentry init uses structured exit codes; every other command exits 0 or 1
  • CliError base class (src/lib/errors.ts) has an exitCode property but no subclass overrides it — all errors default to 1
  • Init wizard defines 4 constants in src/lib/init/constants.ts (10, 20, 30, 50) with 2 more used server-side only (40, 41)

Existing init exit codes

Code Meaning Where defined
0 Success open-sentry-ui step
10 Sentry already installed check-existing-sentry step
20 Platform not detected detect-platform step
30 Dependency install failed install-deps step
40 Codemod plan failed plan-codemods step (server-side only)
41 Codemod apply failed apply-codemods step (server-side only)
50 User stopped after verification verify-changes step

Proposal

  1. Define semantic exit code ranges for the whole CLI (e.g. 1=general, 2=usage/args, 10–19=auth, 20–29=config, etc.)
  2. Have CliError subclasses set appropriate exit codes (e.g. AuthError → 10, ConfigError → 20)
  3. Add a reference page to the docs site listing all exit codes so users can script around them
  4. Backward-compatible — currently everything is 0 or 1, so adding specific codes is purely additive

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions