Skip to content

outcome_from_exit_code() misclassifies any exit code of exactly 130 as "interrupted" #175

Description

@codeforester

Summary

outcome_from_exit_code() treats any exit code equal to 130 as an interruption, even when no KeyboardInterrupt/signal actually occurred.

Details

  • lib/python/base_cli/_lifecycle.py:114-121 (outcome_from_exit_code) special-cases exit_code == ExitCode.INTERRUPTED (130) and unconditionally returns InvocationOutcome("interrupted", "error", exit_code).
  • Reached from outcome_from_exception's click.exceptions.Exit branch (:137) and called from app.py:1016 and app.py:2855.
  • Any command that return 130 (e.g. forwarding a subprocess's exit status) or calls ctx.exit(130) for an unrelated reason gets recorded with outcome: "interrupted" in run.json, in history, and — for JSON mode — as "code": "interrupted" in the error envelope, even though nothing was interrupted.

Impact

Contradicts the README's own outcome table ("another returned nonzero integer → nonzero_return") and ExitCode.INTERRUPTED's documented meaning ("the user interrupted the command with Ctrl+C"). Only KeyboardInterrupt/click.Abort(cause=KeyboardInterrupt) should map to "interrupted".

Suggested fix

Have outcome_from_exit_code() always return "nonzero_return" for non-{0,2} codes; keep the "interrupted" kind exclusive to the exception-based paths in outcome_from_exception.

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

No type

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions