Skip to content

fix: handle YAMLError from schema_yml in apply_schema_overlay#45

Merged
candleindark merged 1 commit intodandi:mainfrom
candleindark:fix-apply-schema-overlay-yaml-error
Mar 26, 2026
Merged

fix: handle YAMLError from schema_yml in apply_schema_overlay#45
candleindark merged 1 commit intodandi:mainfrom
candleindark:fix-apply-schema-overlay-yaml-error

Conversation

@candleindark
Copy link
Copy Markdown
Member

Summary

  • apply_schema_overlay was not catching yaml.YAMLError from
    yaml.safe_load(schema_yml), so invalid YAML in schema_yml would
    propagate as a raw YAMLError instead of the documented ValueError.
  • Wrapped the call in try/except yaml.YAMLError and re-raise as
    ValueError, matching the existing behaviour of apply_yaml_deep_merge.
  • Updated the :raises ValueError: docstring line accordingly.
  • Added test_schema_yml_invalid_yaml_raises_value_error to
    TestApplySchemaOverlay, mirroring the equivalent test in
    TestApplyYamlDeepMerge.

Test plan

  • hatch run test.py3.10:pytest tests/test_tools.py::TestApplySchemaOverlay — all 11 tests pass
  • ruff check . — no issues
  • hatch run types:check — no new errors introduced

🤖 Generated with Claude Code

Wrap yaml.safe_load(schema_yml) in a try/except so invalid YAML raises
ValueError, matching the behaviour of apply_yaml_deep_merge.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@candleindark candleindark merged commit 72797d2 into dandi:main Mar 26, 2026
13 checks passed
@candleindark candleindark deleted the fix-apply-schema-overlay-yaml-error branch March 26, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant