fix(workflows): StepRegistry.add tolerates a corrupted non-dict existing entry#3630
Open
jawwad-ali wants to merge 1 commit into
Open
fix(workflows): StepRegistry.add tolerates a corrupted non-dict existing entry#3630jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
…ing entry
StepRegistry.add read existing = self.data['steps'].get(step_id, {}) then called
existing.get('installed_at', ...). A corrupted-but-parseable registry holding a
non-dict entry (e.g. {'steps': {'foo': 'corrupted'}}) — which _load() accepts,
since it validates only the top-level dict and that 'steps' is a dict — made
add() raise AttributeError. WorkflowRegistry.add was hardened for exactly this
(github#3419); mirror its isinstance guard so a non-dict existing entry is treated as
absent.
Test copies the WorkflowRegistry sibling test for StepRegistry (fails before:
AttributeError on existing.get()).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
StepRegistry.addreads the existing entry then calls.get()on it:A corrupted-but-parseable registry — e.g.
{"steps": {"foo": "corrupted"}}, which_load()accepts because it validates only the top-level dict and thatstepsis a dict — makesadd()raiseAttributeError: 'str' object has no attribute 'get'.Its sibling
WorkflowRegistry.addwas hardened for exactly this in #3419 (existing = raw_existing if isinstance(raw_existing, dict) else {});StepRegistry.addwas left unguarded — a same-file parity gap.Fix
Mirror the WorkflowRegistry guard so a non-dict existing entry is treated as absent.
Test
test_step_registry_add_survives_non_dict_existing_entry(a 1:1 copy of the WorkflowRegistry sibling test): a"corrupted"string entry no longer crashesadd()— fails before (AttributeError), passes after.🤖 Written with the assistance of Claude Code (AI). Bug self-found; fix/tests verified locally (fail-before / pass-after), ruff clean.