Skip to content

Commit d38ebe4

Browse files
mnriemCopilot
andcommitted
fix: derive VALID_SCRIPT_TYPES from shared constant, fail fast on OSError, include all resolved fields in output
- Derive VALID_SCRIPT_TYPES from SCRIPT_TYPE_CHOICES in _agent_config so the valid set cannot drift from the specify init CLI. - Fail fast with a clear error when os.scandir() raises OSError (e.g. permission denied) instead of silently treating the directory as empty. - Include preset, force, and ignore_agent_tools in all output dicts (both fast-fail and normal paths) for consistent interpolation and debugging downstream. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e5f22c3 commit d38ebe4

1 file changed

Lines changed: 31 additions & 5 deletions

File tree

src/specify_cli/workflows/steps/init/__init__.py

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
import os
1212
from typing import Any
1313

14-
from specify_cli._agent_config import DEFAULT_INIT_INTEGRATION
14+
from specify_cli._agent_config import DEFAULT_INIT_INTEGRATION, SCRIPT_TYPE_CHOICES
1515
from specify_cli.workflows.base import StepBase, StepContext, StepResult, StepStatus
1616
from specify_cli.workflows.expressions import evaluate_expression
1717

18-
#: Valid ``script`` values, mirroring ``specify init --script``.
19-
VALID_SCRIPT_TYPES = ("sh", "ps")
18+
#: Valid ``script`` values, derived from the canonical source in _agent_config.
19+
VALID_SCRIPT_TYPES = tuple(SCRIPT_TYPE_CHOICES.keys())
2020

2121
#: Directories the workflow engine may create before steps run.
2222
#: These are excluded from the "non-empty directory" fast-fail check so
@@ -119,8 +119,28 @@ def execute(self, config: dict[str, Any], context: StepContext) -> StepResult:
119119
entry for entry in it
120120
if entry.name not in _ENGINE_OWNED_DIRS
121121
]
122-
except OSError:
123-
non_engine_entries = []
122+
except OSError as exc:
123+
error_message = (
124+
f"Cannot inspect target directory {base!r}: {exc}"
125+
)
126+
return StepResult(
127+
status=StepStatus.FAILED,
128+
output={
129+
"argv": argv,
130+
"project": project,
131+
"here": here,
132+
"integration": integration,
133+
"integration_options": integration_options,
134+
"script": script,
135+
"preset": preset,
136+
"force": force,
137+
"ignore_agent_tools": ignore_agent_tools,
138+
"exit_code": 1,
139+
"stdout": "",
140+
"stderr": error_message,
141+
},
142+
error=error_message,
143+
)
124144
if non_engine_entries:
125145
error_message = (
126146
f"Target directory {base!r} is not empty. Set "
@@ -135,6 +155,9 @@ def execute(self, config: dict[str, Any], context: StepContext) -> StepResult:
135155
"integration": integration,
136156
"integration_options": integration_options,
137157
"script": script,
158+
"preset": preset,
159+
"force": force,
160+
"ignore_agent_tools": ignore_agent_tools,
138161
"exit_code": 1,
139162
"stdout": "",
140163
"stderr": error_message,
@@ -168,6 +191,9 @@ def execute(self, config: dict[str, Any], context: StepContext) -> StepResult:
168191
"integration": integration,
169192
"integration_options": integration_options,
170193
"script": script,
194+
"preset": preset,
195+
"force": force,
196+
"ignore_agent_tools": ignore_agent_tools,
171197
"exit_code": exit_code,
172198
"stdout": stdout,
173199
"stderr": stderr,

0 commit comments

Comments
 (0)