Skip to content

Commit db28bfe

Browse files
committed
Fix workflow @input directory handling
1 parent aafc0ef commit db28bfe

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

src/specify_cli/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5067,8 +5067,12 @@ def _parse_workflow_inputs(
50675067
value = raw_value.strip()
50685068
if value.startswith("@"):
50695069
file_ref = value[1:].strip()
5070-
if file_ref and _resolve_workflow_cli_path(file_ref).exists():
5071-
_, value = _read_workflow_cli_file(file_ref, f"input {key!r}")
5070+
if file_ref:
5071+
candidate_path = _resolve_workflow_cli_path(file_ref)
5072+
if candidate_path.exists() and candidate_path.is_file():
5073+
_, value = _read_workflow_cli_file(
5074+
file_ref, f"input {key!r}"
5075+
)
50725076
inputs[key] = value
50735077

50745078
return inputs

tests/test_workflows.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ def test_missing_at_file_stays_literal(self, literal, project_dir, monkeypatch):
130130

131131
assert inputs == {"assignee": literal}
132132

133+
def test_existing_at_directory_stays_literal(self, project_dir, monkeypatch):
134+
from specify_cli import _parse_workflow_inputs
135+
136+
(project_dir / "some_existing_directory").mkdir()
137+
monkeypatch.chdir(project_dir)
138+
139+
assert _parse_workflow_inputs(["x=@."], None) == {"x": "@."}
140+
assert _parse_workflow_inputs(
141+
["x=@some_existing_directory"],
142+
None,
143+
) == {"x": "@some_existing_directory"}
144+
133145
def test_missing_input_file_fails_cleanly(self, project_dir, monkeypatch):
134146
from specify_cli import _parse_workflow_inputs
135147

@@ -138,6 +150,15 @@ def test_missing_input_file_fails_cleanly(self, project_dir, monkeypatch):
138150
with pytest.raises(ValueError, match="not found"):
139151
_parse_workflow_inputs(None, "missing.json")
140152

153+
def test_input_file_directory_fails_cleanly(self, project_dir, monkeypatch):
154+
from specify_cli import _parse_workflow_inputs
155+
156+
(project_dir / "payload.json").mkdir()
157+
monkeypatch.chdir(project_dir)
158+
159+
with pytest.raises(ValueError, match="not a file"):
160+
_parse_workflow_inputs(None, "payload.json")
161+
141162
def test_input_file_loads_json_object(self, project_dir, monkeypatch):
142163
from specify_cli import _parse_workflow_inputs
143164

0 commit comments

Comments
 (0)