Repository navigation
fix(config): prevent crashes on non-mapping root and non-string extends - #157
Conversation
|
Thank you for this contribution, @X6M-Work — and welcome, as this is the first external contribution to ProFiles! 🎉 Excellent first PR: you targeted a real crash class in the editor diagnostics path, and the fix is exactly the right shape — type guards at the root cause rather than just swallowing errors, plus tests at both the validator and diagnostics levels. I verified the PR locally against a checkout of the branch:
A couple of cosmetic notes for the future (no action needed on this PR): Thanks again — looking forward to more contributions. 🙌 |
Summary
Fixes #119.
When validating YAML drafts,
collect_config_issuesdocuments that it "never raises", but previously crashed on parseable non-mapping roots (e.g. scalar42or a sequence list) and non-hashableextendsvalues (e.g.extends: [b]).Changes
validator.collect_issues:rawis adict, returning aConfigError("", "configuration root must be a mapping")issue otherwise instead of raisingTypeError/AttributeError.raware strings before testing membership.extendsis astrbefore doingextends not in configsand before recursive traversal.diagnostics.collect_config_issues:isinstance(raw, dict)and return a mapping root issue if parsed content is a scalar or sequence.collect_issuesand schema validation in protective try/except blocks to preserve the "never raises" contract.test_diagnostics.pyandtest_validator.py.