The agent that turns websites into APIs!
fix(cli): report capture errors once on stderr
kalil0321edcd92d489b5
diff --git a/src/reverse_api/cli.py b/src/reverse_api/cli.pyindex 1d25e73..543312e 100644--- a/src/reverse_api/cli.py+++ b/src/reverse_api/cli.py@@ -2,6 +2,7 @@ from __future__ import annotationsimport asyncioimport json+import loggingimport osimport randomimport sys@@ -1810,7 +1811,8 @@ def agent(if isinstance(result, dict) and "error" in result:if interactive and result["error"] == "interrupted":return- click.echo(f"error: {result['error'] or 'Agent analysis failed.'}", err=True)+ if not result.get("error_reported"):+ click.echo(f"error: {result['error'] or 'Agent analysis failed.'}", err=True)sys.exit(1)return@@ -2271,17 +2273,17 @@ def run_auto_capture(}except Exception as e:- console.print(f" [red]auto mode error: {escape(str(e) or type(e).__name__)}[/red]")- console.print(f" [dim]{ERROR_CTA}[/dim]")- import traceback-- traceback.print_exc()+ message = str(e) or type(e).__name__+ click.echo(f"error: {message}", err=True)+ click.echo(ERROR_CTA, err=True)+ logging.getLogger(__name__).debug("Auto mode failed", exc_info=True)return {"run_id": run_id,"mode": mode_label,"script_path": None,"usage": {},- "error": str(e) or type(e).__name__,+ "error": message,+ "error_reported": True,}diff --git a/tests/test_cli_agent_json.py b/tests/test_cli_agent_json.pyindex 885a462..4c862f2 100644--- a/tests/test_cli_agent_json.py+++ b/tests/test_cli_agent_json.py@@ -649,7 +649,8 @@ def test_empty_provider_exception_is_failure(tmp_path, error_type, output_flag):assert payload["status"] == "error"assert payload["error"] == error_type.__name__else:- assert f"error: {error_type.__name__}" in result.stderr+ assert result.stderr.count(f"error: {error_type.__name__}") == 1+ assert "Traceback" not in result.stderr@pytest.mark.parametrize("output_flag", ["--json", "--json-stream", "--no-interactive"])