Skip to content

fix(cli): every command reports a DevOpsCLIError through one exit seam, with its exit status and no traceback #2487

Description

@dan-petty

Problem or Motivation

Part 1 of #1006. A command reports a DevOpsCLIError in four ways, and some commands do not report it at all (checked at origin/main 08d70ca, 2026-10-28):

  • OTelTyper(exit_on=<class>) (src/devops_cli/core/cli.py) reports one error class for each app. 14 apps pass it: gh (10), pr (2), openspec and valkey.
  • 40 with exit_on_error(<class>): blocks in 15 command modules report one class for one block.
  • 21 except <class> as exc: ... raise typer.Exit(exc.exit_code) sites write the report by hand: commands/cloudflare.py (9), commands/valkey.py (9), commands/sandbox.py, commands/telemetry.py and commands/scan.py.
  • commands/config.py builds a plain typer.Typer, so its commands do not pass through the OTelTyper.command wrapper.

A DevOpsCLIError that no block catches leaves the command, _delegate (src/devops_cli/main.py) logs it with a traceback and re-raises it, and the process ends with status 1 instead of the error's exit_code.

Proposed Solution & Architectural Design

  • The wrapper in OTelTyper.command reports every DevOpsCLIError that a command raises: print_error(exc.message, safe=True), then typer.Exit(exc.exit_code), with no traceback. An app callback that runs as a command (invoke_without_command=True) gets the same report.
  • exit_on=, the exit_on_error blocks in commands and the hand-rolled sites are deleted. exit_on_error stays only as the wrapper's implementation.
  • commands/config.py builds its app with new_typer().
  • An exception that is not a DevOpsCLIError propagates as it does today.

Target Subsystem

src/devops_cli/core/cli.py and src/devops_cli/commands/.

Existing Tool Considered

Click owns the exit: typer.Exit carries the status, and Click's standalone mode ends the process with it. The seam is one except in the wrapper that every command already passes through. A click.ClickException subclass for DevOpsCLIError was considered: Click prints it with an "Error:" prefix and its own format, which would change every error line, and the error classes would depend on Click.

Acceptance criteria

  • A command registered on new_typer() that raises a DevOpsCLIError subclass with Rich markup in its message exits with that class's exit_code, prints one error line with the markup escaped, and prints no traceback.
  • The same holds for an app callback with invoke_without_command=True.
  • No module under src/devops_cli/commands/ passes exit_on=, uses exit_on_error, or raises typer.Exit(exc.exit_code) from an except of a DevOpsCLIError.
  • A test walks the registered apps and finds no plain typer.Typer.
  • The exit status of each command stays the same for each error class.
  • The tests run offline.

Related

Parent: #1006. Sibling: the exception classes declare their codes as class data. Related: #1372.

Source: #1006

Activity

  1. added
    type/refactor
    source/agent
    status/new
    value/medium
    effort/medium
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/refactor. The change consolidates four error-reporting patterns into one wrapper without altering user-facing exit codes or messages.
    • Priority: P2-Medium. It removes a class of silent-failure bugs but does not block a release or fix a critical defect.
    • Value: Medium. It eliminates inconsistent error reporting across 15 command modules and prevents future commands from missing the report.
    • Effort: Medium. It touches the core wrapper, 15 command modules, and requires new and updated tests, but each change is mechanical.
    • Related: refactor(exceptions): let validators raise own errors and bound details once #1877, which asks for a different change. Both work on the DevOpsCLIError exception system, but #1877 changes what exceptions domain code raises while this candidate changes how the CLI boundary catches and reports them.
  3. added
    priority/p2-medium
    on Oct 28, 2026
  4. added a commit that references this issue on Oct 28, 2026
  5. removed
    status/new
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumsource/agenttype/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions