fix(workflows): validate non-mapping `options` in command step
Fixes #3493.
What
CommandStep.execute() merges step-level options into the workflow-level defaults via dict.update(), but CommandStep.validate() did not check the type of options, and the merge itself was gated only on truthiness (if step_options:). Any truthy non-mapping value therefore passed validation and crashed at run time:
options: [1, 2] -> TypeError: cannot convert dictionary update sequence element #0 to a sequence
options: "foo" -> ValueError: dictionary update sequence element #0 has length 1; 2 is required
Sibling of #3492 (same file, same class of type-validation gap in the command step).
Fix
Same shape as the fix already applied in the shell / while-loop / do-while validators and in #3492:
validate()rejects a non-mappingoptionswith a message that names the field.execute()guards the.update()withisinstance(step_options, dict)so a caller that bypassesWorkflowEngine.validate()(e.g. ad-hocstep.execute(...)) still fails cleanly and the workflow-level defaults survive.
Tests
Two new regression tests in TestCommandStep:
test_validate_rejects_non_mapping_options— a list and a string both report a clear'options' must be a mappingerror.test_execute_non_mapping_options_does_not_crash— the validate-bypass path returnsStepStatus.FAILEDand the workflow-level defaults are preserved unchanged (a malformed step-level override is discarded, not partially applied).
Targeted run:
$ .venv/bin/python -m pytest tests/test_workflows.py::TestCommandStep -q
============================== 12 passed in 0.35s ==============================
Manual test results
Agent: N/A — workflow-engine-only fix, no slash-command surface changed. | OS/Shell: macOS 15 / zsh
| Command tested | Notes |
|---|---|
/speckit.plan |
Not affected — CLI dispatch surface unchanged. TestCommandStep::test_options_merge still passes (well-formed step options are still merged over defaults). |
Only touches src/specify_cli/workflows/steps/command/__init__.py; no templates/commands/*, no scripts/bash|powershell/*, no src/specify_cli/* CLI entry point. Per CONTRIBUTING.md's mapping rules, no slash command's behavior changes.
Relation to #3495
#3495 (input validation, closes #3492) is an independent sibling fix in the same file. Both share the pattern the recent fix(workflows) commits have been applying elsewhere. They land cleanly on top of each other; happy to rebase either way.
AI disclosure
Per CONTRIBUTING.md#ai-contributions-in-spec-kit: this PR (bug identification, patch, and tests) was prepared with Claude (Anthropic) assistance in an autonomous agent session. Reproducer executed against a fresh clone of main; the fix follows the existing type-validation pattern in sibling step validators; the workflow test suite was run green before submission. The change is minimal — one isinstance guard in execute(), one check in validate(), two focused tests.
🤖 Generated with Claude Code