fix(workflows): reject falsy non-mapping step.yml in step add - #4321
Open
Noor-ul-ain001 wants to merge 2 commits into
Open
fix(workflows): reject falsy non-mapping step.yml in step add#4321Noor-ul-ain001 wants to merge 2 commits into
Noor-ul-ain001 wants to merge 2 commits into
Conversation
`workflow_step_add` parses a fetched `step.yml` with
`_yaml.safe_load(...) or {}`, which coerces a FALSY non-mapping
top-level document (`[]`, `false`, `0`, `''`) to `{}` before the
`isinstance(meta, dict)` shape check runs. The command then proceeds
with `meta = {}`, derives `step_meta = {}` and `type_key = ""`, and
reports the unrelated "step.yml missing 'step.type_key' field"
instead of the real problem: "step.yml must be a YAML mapping". A
TRUTHY non-mapping document (a bare string) already reported the
correct error — this was an inconsistency.
Same falsy-or-coerce shape as the catalog-config bugs fixed elsewhere
in workflows/catalog.py, presets/__init__.py, and integrations
(github#4187) this cycle.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FW9fAYsCBCAgdKWovtSyqt
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Explicit YAML null documents remain coerced to an empty mapping and receive the wrong error.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes workflow step validation so falsy non-mapping YAML values report a mapping-shape error.
Changes:
- Removes broad falsy-to-dictionary coercion.
- Adds regression coverage for lists, booleans, numbers, and empty strings.
File summaries
| File | Description |
|---|---|
src/specify_cli/workflows/_commands.py |
Refines step.yml shape validation. |
tests/test_workflows.py |
Tests falsy non-mapping documents. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+3376
to
+3377
| if meta is None: | ||
| meta = {} |
An explicit null document (null/~/NULL) parses to the same None as a
genuinely empty document, so it was silently coerced to {} and
misreported as the unrelated "missing step.type_key" error instead of
the mapping-shape error, per Copilot review on PR github#4321. Use
yaml.compose to tell the two apart, matching the sibling loaders
(yamlio.py, integrations/catalog.py, overlays/layer_sources.py).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0147sii7uC56YzAu2Ep9qH94
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
workflow_step_add(src/specify_cli/workflows/_commands.py) parses a fetchedstep.ymlwith_yaml.safe_load(step_yml_content.decode("utf-8")) or {}.or {}coerces a falsy non-mapping top-level document ([],false,0,'') to{}before theif not isinstance(meta, dict): ...shape check runs. The command then proceeds withmeta = {}, derivesstep_meta = meta.get("step", {})→{}andtype_key = "", and reports the unrelated"step.yml missing 'step.type_key' field"instead of the real problem:"step.yml must be a YAML mapping".isinstancecheck and reports the right error — this was an inconsistency between falsy and truthy malformed inputs.workflows/catalog.py(WorkflowCatalog/StepCatalog),presets/__init__.py(PresetCatalog._load_catalog_config), andintegrations(fix(integrations): report a falsy non-mapping integration descriptor as a shape error #4187).Test plan
test_add_rejects_falsy_non_mapping_step_ymltoTestWorkflowStepAddCLI, parametrized over[],false,0,'', mocking the HTTP fetch sostep.yml's body is the falsy document."missing 'step.type_key'"message) and pass with it.TestWorkflowStepAddCLIin full — 24 passed; the 1 remaining failure (test_add_rejects_symlinked_steps_base_dir) is a pre-existing Windows symlink-elevation failure unrelated to this change (reproduces on an unmodified checkout).Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01FW9fAYsCBCAgdKWovtSyqt