spec-kit
spec-kit copied to clipboard
fix(workflows): validate command step input/options are mappings
Description
CommandStep.validate() only checks that command is present. But execute() then does:
for key, value in input_data.items(): ... # input_data = config.get("input", {})
options.update(step_options) # step_options = config.get("options", {})
So a non-mapping input: or options: (e.g. a YAML list or scalar) raises AttributeError at run time, bypassing the per-step FAILED/continue_on_error contract. Every sibling step validates the shape of its structured fields (switch 'cases', fan-out 'step') — CommandStep was the lone outlier.
Fix
validate(): report'input' must be a mapping/'options' must be a mapping(mirroring the sibling steps).execute(): defense-in-depth — coerce a non-mappinginput/skip non-mappingoptionsrather than crash, since the engine does not auto-validate before running a step.
Testing
uvx ruff checkclean;TestCommandSteppasses (11 tests).- New
test_validate_rejects_non_mapping_input_and_options:input∈ {None, str, list, int} andoptions: 42now return the mapping error (fail-before/pass-after); a valid mapping config still returns[];execute()withinput: Nonereturns a result instead of raising.
AI Disclosure
- [x] I did use AI assistance (describe below)
Found and fixed with Claude Code (Claude Opus 4.8) under my direction. AI identified the validate()-contract gap versus the sibling steps; I reproduced the run-time AttributeError, confirmed the validate + execute-guard fix, and reviewed the diff before submitting.