What
Every blade-ai CLI command exposes --output/-o with help text json|yaml, but the value is an unvalidated str passed to format_output() in blade-ai/src/chaos_agent/cli/output.py:
if output_format == "yaml" and HAS_YAML:
return yaml.dump(...)
else:
return json.dumps(...)
So any unrecognized format silently returns JSON — --output xml, --output ymal (typo), etc. produce JSON with no error and no warning. The same silent fallback happens for --output yaml if PyYAML is somehow unavailable.
Affected commands (8)
config, capabilities_cmd, list_cmd, metric, confirm, inject, version, recover — each declares:
output: str = typer.Option("json", "--output", "-o", help="Output format: json|yaml")
Why it matters
A user scripting against the CLI who typos --output or requests an unsupported format gets JSON back silently, with no signal that their flag was ignored. For a tool whose output is consumed by automation, silently ignoring an invalid flag is a correctness problem.
Proposed fix
- Add an
OutputFormat(str, Enum) in cli/output.py and type the --output option as that enum across all 8 commands, so Typer rejects invalid values at the CLI boundary and auto-generates accurate help.
- Make
format_output() validate defensively: raise a clear ValueError on an unknown format, and a clear "install pyyaml" error when yaml is requested but PyYAML is unavailable (PyYAML is a declared dependency, so this only fires on a broken install).
Single, self-contained change (one helper + option typing + tests). Happy to submit a PR. (Observed on commit c571faa.)
Environment: blade-ai v0.3.0
What
Every blade-ai CLI command exposes
--output/-owith help textjson|yaml, but the value is an unvalidatedstrpassed toformat_output()inblade-ai/src/chaos_agent/cli/output.py:So any unrecognized format silently returns JSON —
--output xml,--output ymal(typo), etc. produce JSON with no error and no warning. The same silent fallback happens for--output yamlif PyYAML is somehow unavailable.Affected commands (8)
config,capabilities_cmd,list_cmd,metric,confirm,inject,version,recover— each declares:Why it matters
A user scripting against the CLI who typos
--outputor requests an unsupported format gets JSON back silently, with no signal that their flag was ignored. For a tool whose output is consumed by automation, silently ignoring an invalid flag is a correctness problem.Proposed fix
OutputFormat(str, Enum)incli/output.pyand type the--outputoption as that enum across all 8 commands, so Typer rejects invalid values at the CLI boundary and auto-generates accurate help.format_output()validate defensively: raise a clearValueErroron an unknown format, and a clear "install pyyaml" error whenyamlis requested but PyYAML is unavailable (PyYAML is a declared dependency, so this only fires on a broken install).Single, self-contained change (one helper + option typing + tests). Happy to submit a PR. (Observed on commit
c571faa.)Environment: blade-ai v0.3.0