fix(workflows): reject falsy non-mapping step.yml in step add - #4321
Open
Noor-ul-ain001 wants to merge 1 commit into
Open
fix(workflows): reject falsy non-mapping step.yml in step add#4321Noor-ul-ain001 wants to merge 1 commit into
Noor-ul-ain001 wants to merge 1 commit 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
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