fix(cli): reject unsupported agentmain arguments - #742
Open
imMamdouhaboammar wants to merge 1 commit into
Open
Conversation
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
Fixes the fail-silent CLI behavior described in upstream issue #566.
agentmain.pyusesparse_known_args()because reflect scripts accept extra--key valuepairs. Before this patch, unknown arguments could be converted into reflect arguments even when--reflectwas not active, allowing unsupported commands such as--goalto fall through into normal interactive startup instead of failing at the CLI boundary.Changes
--reflectwas not supplied--key valueextras supported--name --otherk[2:]instead of normalizing malformed keys vialstrip('-')Regression coverage
--goal dummy-goal.jsonwithout--reflectexits through argparse with code 2 and anunrecognized argumentsdiagnostic--reflect script.py --nameis rejected--name --otheris rejected---name hive-masteris rejected--reflect ''is rejected explicitly as an empty script path--reflect script.py --name hive-masterremains supported and the reflect script receivesname=hive-masterThe subprocess harness is isolated from the developer checkout: it runs from a temporary working directory with an empty
mykey.py, no-op plugin hooks,PYTHONNOUSERSITE=1, and only the temporary state plus repository onPYTHONPATH.Verification
--goalentered runtime instead of failing at argparse; incomplete reflect extras were silently accepted31162976599passed after isolating the subprocess environment31163651223failed exactly on---name hive-masterand the explicit empty reflect path, while existing valid reflect behavior passed31163720543:py_compile, all four regression methods and subcases, andgit diff --checkmainas one commit changing onlyagentmain.pyand the focused regression testNo dependency or configuration change is added.
The connected GitHub integration can write to this fork but direct creation of the upstream PR returned
403 Resource not accessible by integration, so this fork PR is the clean contribution branch forlsdefine/GenericAgent.