File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -521,8 +521,11 @@ def _hide_suppressed_subparsers(parser: argparse.ArgumentParser) -> None:
521521def parse_args (args = None ):
522522 """Parse command line arguments."""
523523 parser = build_parser ()
524- # Use parse_known_args to allow Hydra to handle its own arguments
525- return parser .parse_known_args (args )
524+ # Fail fast on unknown flags so typos don't silently get ignored.
525+ parsed , remaining = parser .parse_known_args (args )
526+ if remaining :
527+ parser .error (f"unrecognized arguments: { ' ' .join (remaining )} " )
528+ return parsed , remaining
526529
527530
528531def main ():
Original file line number Diff line number Diff line change 66from eval_protocol .cli import parse_args
77
88
9+ def test_unknown_flag_fails_fast (capsys ):
10+ with pytest .raises (SystemExit ) as e :
11+ parse_args (["create" , "rft" , "--definitely-not-a-real-flag" ])
12+ assert e .value .code == 2
13+ out = capsys .readouterr ()
14+ # argparse writes errors to stderr
15+ assert "unrecognized arguments" in out .err
16+ assert "--definitely-not-a-real-flag" in out .err
17+
18+
919@pytest .mark .skip (reason = "preview and deploy commands are currently disabled in cli.py" )
1020class TestCliArgParsing :
1121 # --- Tests for 'preview' command ---
You can’t perform that action at this time.
0 commit comments