Skip to content

Commit 2322fdb

Browse files
MarkusCopilot
andcommitted
fix(workflows): address remaining PR #2408 review findings
- engine.py: strip whitespace from integration value in _resolve_integration_auto(); whitespace-only strings like ' ' now fall back to 'copilot' instead of being returned as-is - __init__.py: define INTEGRATION_JSON locally instead of importing from workflows.constants; avoids executing the workflows package __init__ (which registers all step types) during CLI startup for commands that don't use workflows - tests: add test for whitespace-only integration value fallback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 51f9acd commit 2322fdb

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/specify_cli/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@
5757
# For cross-platform keyboard input
5858
import readchar
5959

60-
from .workflows.constants import INTEGRATION_JSON
60+
# Keep this local so importing specify_cli does not import the workflows package
61+
# (whose package initialization registers steps and imports all workflow modules).
62+
INTEGRATION_JSON = ".specify/integration.json"
6163

6264
GITHUB_API_LATEST = "https://api.github.com/repos/github/spec-kit/releases/latest"
6365

src/specify_cli/workflows/engine.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,10 @@ def _resolve_integration_auto(self) -> str:
760760
return self._AUTO_FALLBACK
761761
if isinstance(data, dict):
762762
value = data.get("integration")
763-
if isinstance(value, str) and value:
764-
return value
763+
if isinstance(value, str):
764+
normalized_value = value.strip()
765+
if normalized_value:
766+
return normalized_value
765767
return self._AUTO_FALLBACK
766768

767769
@staticmethod

tests/test_workflows.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,3 +2076,22 @@ def test_resolve_inputs_auto_oserror_falls_back_to_copilot(self, project_dir):
20762076

20772077
step_output = state.step_results["specify"]["output"]
20782078
assert step_output["integration"] == "copilot"
2079+
2080+
def test_resolve_inputs_auto_whitespace_only_falls_back_to_copilot(self, project_dir):
2081+
"""When integration.json has a whitespace-only value, 'auto' falls back to 'copilot'."""
2082+
from unittest.mock import patch
2083+
from specify_cli.workflows.engine import WorkflowEngine, WorkflowDefinition
2084+
2085+
int_json = project_dir / ".specify" / "integration.json"
2086+
int_json.write_text(json.dumps({"integration": " "}), encoding="utf-8")
2087+
2088+
definition = WorkflowDefinition.from_string(self._make_workflow_yaml())
2089+
engine = WorkflowEngine(project_dir)
2090+
2091+
with patch(
2092+
"specify_cli.workflows.steps.command.shutil.which", return_value=None
2093+
):
2094+
state = engine.execute(definition)
2095+
2096+
step_output = state.step_results["specify"]["output"]
2097+
assert step_output["integration"] == "copilot"

0 commit comments

Comments
 (0)