Skip to content

Commit 55b667c

Browse files
committed
Route workflow JSON errors to stderr
Assisted-by: OpenAI Codex (model: GPT-5, autonomous)
1 parent 276edcc commit 55b667c

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

‎src/specify_cli/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,10 +770,10 @@ def workflow_run(
770770
specify_dir = project_root / ".specify"
771771
if specify_dir.is_symlink():
772772
where = " in current directory" if override is None else f": {specify_dir}"
773-
console.print(f"[red]Error:[/red] Refusing to use symlinked .specify path{where}")
773+
err_console.print(f"[red]Error:[/red] Refusing to use symlinked .specify path{where}")
774774
raise typer.Exit(1)
775775
if specify_dir.exists() and not specify_dir.is_dir():
776-
console.print("[red]Error:[/red] .specify path exists but is not a directory")
776+
err_console.print("[red]Error:[/red] .specify path exists but is not a directory")
777777
raise typer.Exit(1)
778778
else:
779779
project_root = _require_specify_project()

‎src/specify_cli/integrations/_helpers.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from .._agent_config import SCRIPT_TYPE_CHOICES
1111
from .._console import console
12-
from .._project import _resolve_init_dir_override as _resolve_init_dir_override # noqa: F401
1312
from ..integration_runtime import (
1413
invoke_separator_for_integration as _invoke_separator_for_integration,
1514
resolve_integration_options as _resolve_integration_options_impl,

‎tests/test_init_dir_cli.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,26 @@ def test_override_rejects_symlinked_specify(tmp_path, monkeypatch):
269269
result = runner.invoke(app, ["workflow", "run", str(workflow_file)])
270270
assert result.exit_code != 0
271271
assert "Refusing to use symlinked .specify path" in result.output
272+
273+
274+
def test_override_rejects_symlinked_specify_json_error_stays_off_stdout(tmp_path, monkeypatch):
275+
"""`workflow run --json <file>` must keep this hard error off stdout."""
276+
web = tmp_path / "web"
277+
web.mkdir()
278+
real = tmp_path / "real-specify"
279+
real.mkdir()
280+
try:
281+
(web / ".specify").symlink_to(real, target_is_directory=True)
282+
except (OSError, NotImplementedError):
283+
pytest.skip("Symlinks are not available in this environment")
284+
elsewhere = tmp_path / "elsewhere"
285+
elsewhere.mkdir()
286+
workflow_file = elsewhere / "wf.yml"
287+
workflow_file.write_text(_workflow_yaml("symlink-json-run"), encoding="utf-8")
288+
monkeypatch.chdir(elsewhere)
289+
monkeypatch.setenv("SPECIFY_INIT_DIR", str(web))
290+
291+
result = runner.invoke(app, ["workflow", "run", str(workflow_file), "--json"])
292+
assert result.exit_code != 0
293+
assert result.stdout == ""
294+
assert "Refusing to use symlinked .specify path" in result.stderr

0 commit comments

Comments
 (0)