Repository navigation
Keep the real exit status of kiwi-ng - #3096
Open
Test-bot-cell wants to merge 1 commit into
Open
Test-bot-cell wants to merge 1 commit into
Test-bot-cell wants to merge 1 commit into
Conversation
Cli.__init__ runs the typer application in standalone mode, which always ends with SystemExit once the command line is parsed. The exception was swallowed and, when no command callback had run (--help, --version, a manual page request), sys.exit(1) was forced; usage errors (status 2) were also turned into status 1. The status of the SystemExit is now kept: 0 for a clean exit without a command, the real code for a usage error. main() also passed the SystemExit object to sys.exit() instead of its code, which Python reports as status 1; the code is passed through unchanged. Found while packaging kiwi 11.1.5 for a Ubuntu derivative: scripts testing `kiwi-ng --version` saw status 1. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
kiwi-ng --version,kiwi-ng --helpand a manual page request (kiwi-ng system build help) exit with status 1, and usage errors exit with status 1 instead of 2:Two causes:
Cli.__init__runs the typer application in standalone mode, which always ends withSystemExitonce the command line is parsed. The exception was swallowed and, when no command callback had run (--help,--version, a manual page request),sys.exit(1)was forced; usage errors (status 2) were also turned into status 1.main()inkiwi/kiwi.pypassed theSystemExitobject tosys.exit()instead of its code, which Python reports as status 1.Change
kiwi/cli.py: keep the status of theSystemExitraised by typer: the real code for a usage error, 0 for a clean exit without a command to run. The existingsys.exit(1)when no command was loaded and nothing exited is unchanged.kiwi/kiwi.py: pass theSystemExitcode through unchanged.test/unit/cli_test.py: regression testtest_exit_status_without_command(--versionand--helpexit 0, an unknown option exits 2).Testing
pytest test/unit/cli_test.py: 27 passed (26 existing + the new test), run against the patched package installed on Ubuntu 26.04.--version,--help,system build --help,image info --helpandsystem build helpexit 0;--no-such-optionandsystem buildwithout options exit 2; a successfulsystem buildis not affected (normal return path).Found while packaging kiwi 11.1.5 for an Ubuntu derivative: scripts testing
kiwi-ng --versionsaw status 1.🤖 Generated with Claude Code