spec-kit icon indicating copy to clipboard operation
spec-kit copied to clipboard

fix(workflows): validate command step input/options are mappings

Open jawwad-ali opened this issue 5 months ago • 0 comments

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-mapping input/skip non-mapping options rather than crash, since the engine does not auto-validate before running a step.

Testing

  • uvx ruff check clean; TestCommandStep passes (11 tests).
  • New test_validate_rejects_non_mapping_input_and_options: input ∈ {None, str, list, int} and options: 42 now return the mapping error (fail-before/pass-after); a valid mapping config still returns []; execute() with input: None returns 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.

jawwad-ali avatar Jun 30 '26 16:06 jawwad-ali