fix(workflows): reject a non-string 'command' in command-step#3596
Open
Noor-ul-ain001 wants to merge 1 commit into
Open
fix(workflows): reject a non-string 'command' in command-step#3596Noor-ul-ain001 wants to merge 1 commit into
Noor-ul-ain001 wants to merge 1 commit into
Conversation
`CommandStep.validate` only checked that a `command` field is *present*,
never its type. On an unvalidated run (the engine does not auto-validate
before `execute`) a non-string `command` — null, a list, an int — was
passed straight through `_try_dispatch` to the integration's
`build_command_invocation`, which does `command_name.startswith("speckit.")`
and crashes the whole workflow with a raw `AttributeError` once a
resolvable integration with an installed CLI is found.
Guard both paths, mirroring the sibling steps:
- `validate()` rejects a non-string `command` (like prompt-step `prompt`
github#3582 and shell-step `run`).
- `execute()` fails the step cleanly with the same contract error before
dispatch (like the existing `input`/`options` guards in this file), so
an unvalidated run FAILs the step instead of crashing the run.
An expression like `{{ inputs.cmd }}` is still a string, so it stays valid.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds robust type validation for workflow command steps, preventing non-string commands from crashing dispatch.
Changes:
- Rejects non-string
commandvalues during validation and execution. - Adds coverage for validation and clean step failure behavior.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/workflows/steps/command/__init__.py |
Adds command type guards. |
tests/test_workflows.py |
Tests invalid command handling. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Medium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CommandStep.validateonly checked that acommandfield is present, never its type. But the workflow engine does not auto-validate a step before callingexecute, so on an unvalidated run a non-stringcommand—null, a list, an int — was passed straight through_try_dispatchto the integration'sbuild_command_invocation, which does:Once a resolvable integration with an installed CLI is found, this crashes the entire workflow run with a raw
AttributeErrorinstead of failing just the step.Confirmed directly:
This is the same class of gap that #3582 closed for the prompt-step
promptfield —validate()checked presence only whileexecute()fed the value to the CLI layer.Fix
Guard both paths, matching the sibling steps already in this file:
validate()rejects a non-stringcommand, mirroring prompt-stepprompt(fix(workflows): reject a non-string prompt in prompt-step validate() #3582) and shell-steprun.execute()fails the step cleanly with the same contract error before dispatch, mirroring the existinginput/optionsguards inCommandStep.execute— so an unvalidated run FAILs the step (honouringcontinue_on_error) instead of crashing the run.An expression like
{{ inputs.cmd }}is still astr, so it stays valid.Tests
Added to
TestCommandStep:test_validate_rejects_non_string_command(null / list / int / dict, plus accepts a plain string and an expression)test_execute_non_string_command_fails_cleanly(patchesshutil.whichso dispatch would actually be attempted absent the guard — proving the guard prevents the crash)Verified test-the-test: with the source fix stashed,
validate()misses the bad value andexecute()crashes atbuild_command_invocationwith the rawAttributeError; with the fix, all 13TestCommandSteptests pass. The 20 unrelatedtest_workflows.pyfailures are the pre-existing Windows symlink-guard tests that require elevation.🤖 Generated with Claude Code