FIX: pyrit_shell run fails for every scenario with a flag-collision error - #2303
Merged
Merged
Conversation
rlundeen2
approved these changes
Jul 31, 2026
rlundeen2
reviewed
Jul 31, 2026
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.
Bug Description
Running any scenario from
pyrit_shellfailed before argument parsing with:Root cause: The shell registers each of a scenario's parameters as a CLI flag, using the full list from the API (
scenario_meta.supported_parameters). That list combines the scenario's custom parameters with the framework's common parameters (memory_labels,max_concurrency,max_retries), which normalize to flags that already exist as built-in shell flags. The collision guard_validate_scenario_flag_collisionsraised on the first such clash (memory_labels) instead of skipping it. Since every scenario carries the common parameters,runwas broken universally.pyrit_scanwas unaffected: its_add_scenario_params_from_apisilently skips any scenario flag that already exists as a built-in. The inconsistency between the two entry points was the bug.Fix
Make the shell mirror
pyrit_scan. Replaced_validate_scenario_flag_collisionswith_resolve_scenario_flag_collisionsinpyrit/cli/_cli_args.py, which silently drops any scenario spec whose flag is already taken — by a built-in flag or an earlier scenario param — so the earlier owner keeps the flag (first wins). This matchespyrit_scan._add_scenario_params_from_api, which skips any flag already registered on the parser, so both entry points now accept the same inputs.parse_run_argumentsnow uses the returned filtered specs rather than relying on a validator side effect.Testing
tests/unit/cli/test_cli_args.py::test_parse_run_arguments_skips_scenario_params_colliding_with_builtins— reproduces theairt.scamcase (common params present) and assertsrunparses successfully while the scenario's custom--max-turnsflag still works.tests/unit/cli/test_cli_args.py::test_parse_run_arguments_first_wins_on_scenario_vs_scenario_collision— confirms two scenario params normalizing to the same flag resolve first-wins (parity withpyrit_scan), not an error.test_cli_args.py+test_pyrit_shell.pysuites pass (86/86), no regressions.