Skip to content

Commit 427ef48

Browse files
author
Federico De Ponte
committed
Keep CLI errors off structured stdout
1 parent e826f2f commit 427ef48

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/skyroute/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def scan(
269269
provider=provider,
270270
)
271271
except ValueError as e:
272-
console.print(f"[red]{e}[/red]")
272+
status_console.print(f"[red]{e}[/red]")
273273
raise typer.Exit(1)
274274

275275
names = ", ".join(p.name for p in engine._providers)

tests/test_cli.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,21 @@ def test_scan_reports_total_provider_failure():
152152
Path(config_path).unlink(missing_ok=True)
153153

154154

155+
def test_scan_missing_provider_creds_keeps_stdout_clean_in_json_mode():
156+
config_path = _write_scan_config()
157+
try:
158+
with patch.dict(os.environ, {}, clear=True):
159+
result = runner.invoke(
160+
app,
161+
["scan", "--config", config_path, "--provider", "duffel", "--json"],
162+
)
163+
assert result.exit_code == 1
164+
assert result.stdout == ""
165+
assert "SKYROUTE_DUFFEL_TOKEN" in result.stderr
166+
finally:
167+
Path(config_path).unlink(missing_ok=True)
168+
169+
155170
def test_scan_warns_on_partial_results():
156171
config_path = _write_scan_config()
157172
try:

0 commit comments

Comments
 (0)