Report invalid --format-options as a CLI error, not a traceback - #1938
Open
VXNCXNX wants to merge 1 commit into
Open
Report invalid --format-options as a CLI error, not a traceback#1938VXNCXNX wants to merge 1 commit into
VXNCXNX wants to merge 1 commit into
Conversation
Invalid --format-options values now produce a regular CLI error instead of an unhandled ArgumentTypeError traceback. The --traceback flag still re-raises for debugging.
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.
An invalid
--format-optionsvalue exits with an unhandledargparse.ArgumentTypeErrortraceback instead of the normal HTTPie error:Same for an unknown section (
--format-options=json) or key (--format-options=json.nope:1)._process_format_optionscallsparse_format_optionsoutside argparse's own type machinery, so the error escapes to the top level. It is now caught and routed throughself.error, which is what_guess_methodand_parse_itemsalready do a few lines above;--tracebackstill re-raises, matching those two.After the fix the same command prints
error: --format-options: invalid value 'x' ...and exits 1. Three parametrized cases added intests/test_output.py. Suite is green apart from two pre-existing big5 charset failures intest_encoding.py, identical on an unmodified checkout: 1020 passed, 2 failed.AI disclosure: written with Claude Code. I ran the CLI before and after and checked the mutation myself.