fix(extensions): coerce non-mapping YAML config roots to {} in ConfigManager#3345
Open
jawwad-ali wants to merge 1 commit into
Open
fix(extensions): coerce non-mapping YAML config roots to {} in ConfigManager#3345jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
…Manager
ConfigManager._load_yaml_config returned yaml.safe_load(...) or {}, which
only guards falsy roots — a truthy non-mapping root (a YAML list or
scalar) flows straight into _merge_configs, whose .items() raises
AttributeError. get_config()/has_value()/get_value() then crash, and via
should_execute_hook's blanket 'except Exception: return False' every
config-based hook condition for that extension is silently disabled.
Coerce a non-dict root to {}, mirroring the existing non-dict-root guard
in get_project_config(). Hardens all three call sites in one place.
Co-Authored-By: Claude Fable 5 <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.
Description
ConfigManager._load_yaml_configguards only falsy YAML roots:A truthy non-mapping root — a YAML list (
- foo) or a scalar (just a string) — passes straight through, then_merge_configsdoes.items()on it:reproduced on main @
bba473cviaConfigManager(root, 'jira').get_config()with a list-rootjira-config.yml.has_value/get_valuecrash the same way, and — worse —HookExecutor.should_execute_hookwraps evaluation in a blanketexcept Exception: return False, so a malformed config file silently disables everyconfig.*hook condition for that extension instead of surfacing an error.Fix
Coerce a non-
dictroot (list/scalar, orNonefor an empty file) to{}, mirroring the existing non-dict-root guard already present inget_project_config(). One place hardens all three callers (_get_extension_defaults,_get_project_config,_get_local_config).Testing
New
TestConfigManagerNonMappingYaml(5 tests, all fail-before / pass-after, verified by source-stash):get_config()return{}instead of raising;has_value/get_valuedon't raise;local-config.ymlstill layers over a malformed (list-root) project config;HookExecutor._evaluate_condition('config.x is set', 'jira')returnsFalsecleanly (asserted directly, sinceshould_execute_hookmasks the exception).uvx ruff checkclean.AI Disclosure
Found and fixed with Claude Code (Claude Fable 5) under my direction. AI traced the crash from
_load_yaml_configthrough_merge_configsinto the swallowed hook exception; I reproduced it, verified fail-before/pass-after, and reviewed the diff before submitting.