Repository navigation
fix(cli): report a --data value without "=" as a usage error - #2121
Open
qianeric-backup wants to merge 1 commit into
Open
qianeric-backup wants to merge 1 commit into
qianeric-backup wants to merge 1 commit into
Conversation
_set_override_data() unpacks arg.split("=", 1) without checking that the
separator is there, so `--data foo` raises a bare ValueError that the
top-level handler reports as an internal error, complete with a Rich
traceback, a pyinfra-debug.log and a request to file a bug report.
Raise a CliError with the documented key=value format instead.
qianeric-backup
marked this pull request as ready for review
November 27, 2026 06:00
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.
pyinfra @local debug-inventory --data foo(a--datavalue without the=valuepart) is reported as an internal error:_set_override_data()unpacksarg.split("=", 1)without checking that the separator is there, so a typo becomes a bareValueErrorthat reaches the top-level handler and is reported as a bug in pyinfra. Thekey=valuecontract is already documented on the option itself:@click.option("--data", ..., help="Add data to the deploy, e.g. `--data key=value`.")After:
No
pyinfra-debug.log, no traceback, no "submit a bug report" prompt — the exit code is unchanged and the message is aCliError, the same type the neighbouring argument paths raise (pyinfra_cli/cli.py:324,:649,:661).pyinfra_cli/commands.py:47guards the identicalkey=valueunpack withif "=" in command:, so the missing separator is already treated as a user error elsewhere.This mirrors the earlier fix of the same shape,
fix(cli): raise clear error for missing inventory files(#2095).--data key=value,--data key=a=b(value containing=) and the no---datapath are unchanged — verified byte-for-byte against the unpatched tree.Tests
tests/test_cli/test_cli.py::TestCliOverrideData— three cases: a value without=raises,key=valueis accepted, andkey=a=bkeeps thesplit("=", 1)semantics. The first fails without the change and all three pass with it. Suite:1 failed, 2308 passed→2309 passed;ruff check/ruff format --checkclean on both trees.AI usage
This change was produced with an AI coding assistant (Claude), used to locate the traceback path, write the guard and the tests, and run the before/after verification. Every line was reviewed and the behaviour above was re-checked by hand against the unpatched tree.