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.
|
The red CI here is
httpie's own Root cause, since it is two lines to reproduce: >>> import charset_normalizer as cn # 3.5.1
>>> cn.from_bytes(('卷首'*9)[:17].encode('big5')).best().encoding
'johab'The detector settles on To be fair to the library, the fixture is a short, highly repetitive payload, which is close to the worst case for statistical charset detection, and big5 and johab overlap in that byte range. So this reads more like an over-specified test than a regression in the dependency. Happy to send a separate PR for it if that would help, either pinning the dependency or making the fixture less ambiguous. I have left it out of this one since it is unrelated to the |
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.