Skip to content

fix(ctl): let typer.Exit propagate so CLI commands exit without a traceback#1048

Draft
ogenstad wants to merge 1 commit into
stablefrom
pog-catch-typer-exit-IHS-237
Draft

fix(ctl): let typer.Exit propagate so CLI commands exit without a traceback#1048
ogenstad wants to merge 1 commit into
stablefrom
pog-catch-typer-exit-IHS-237

Conversation

@ogenstad
Copy link
Copy Markdown
Contributor

@ogenstad ogenstad commented May 28, 2026

Why

Newer versions of typer behave differently and produce an error that's not as friendly as we'd want and we don't want to show that error.

Closes #1047

What changed

  • Catch error from typer early and avoid showing it to the end user
  • Tests

Summary by cubic

Fixes infrahubctl so commands that raise typer.Exit exit cleanly without the "Error: 1" line or a traceback. Addresses IHS-237 by ensuring infrahubctl schema load prints only the human-readable error and exits with code 1.

  • Bug Fixes
    • Let typer.Exit propagate in catch_exception (sync and async) so Typer handles the exit without a traceback.
    • Removed interception of click.exceptions.Exit from handle_exception.
    • Added tests to confirm the clean exit, correct code, and no "Error: 1" or traceback.

Written for commit 712ffcf. Summary will update on new commits.

Review in cubic

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

Re-trigger cubic

@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

❗ There is a different number of reports uploaded between BASE (7f17fb8) and HEAD (712ffcf). Click for more details.

HEAD has 8 uploads less than BASE
Flag BASE (7f17fb8) HEAD (712ffcf)
python-3.11 2 1
python-3.12 2 1
python-3.10 2 1
python-3.14 2 1
python-3.13 2 1
python-filler-3.12 2 1
integration-tests 2 0
@@            Coverage Diff             @@
##           stable    #1048      +/-   ##
==========================================
- Coverage   81.54%   74.41%   -7.14%     
==========================================
  Files         134      134              
  Lines       11468    11469       +1     
  Branches     1735     1734       -1     
==========================================
- Hits         9352     8535     -817     
- Misses       1569     2392     +823     
+ Partials      547      542       -5     
Flag Coverage Δ
integration-tests ?
python-3.10 54.57% <100.00%> (+<0.01%) ⬆️
python-3.11 54.57% <100.00%> (-0.02%) ⬇️
python-3.12 54.59% <100.00%> (+0.02%) ⬆️
python-3.13 54.59% <100.00%> (+<0.01%) ⬆️
python-3.14 54.57% <100.00%> (-0.02%) ⬇️
python-filler-3.12 22.66% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/ctl/utils.py 68.75% <100.00%> (+0.21%) ⬆️

... and 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

infrahubctl: typer.Exit leaks raw traceback on schema load failure

1 participant