Skip to content

Raise a clear error for empty YAML files#1482

Merged
romanlutz merged 5 commits intomicrosoft:mainfrom
biefan:fix-empty-yaml-seed-datasets
Apr 15, 2026
Merged

Raise a clear error for empty YAML files#1482
romanlutz merged 5 commits intomicrosoft:mainfrom
biefan:fix-empty-yaml-seed-datasets

Conversation

@biefan
Copy link
Copy Markdown
Contributor

@biefan biefan commented Mar 16, 2026

Summary

  • reject empty YAML inputs in YamlLoadable.from_yaml_file() with a clear ValueError
  • add regression coverage for both SeedDataset.from_yaml_file() and ConfigurationLoader.from_yaml_file()

Problem

yaml.safe_load() returns None for empty or whitespace-only YAML files. YamlLoadable.from_yaml_file() currently forwards that None into downstream constructors, which surfaces as internal AttributeError/TypeError exceptions depending on the caller.

Two real call paths affected today are SeedDataset.from_yaml_file() and ConfigurationLoader.from_yaml_file(), both of which currently fail with low-level exceptions instead of a clear validation error.

Testing

  • .venv/bin/pytest tests/unit/models/test_seed.py tests/unit/setup/test_configuration_loader.py -q

romanlutz and others added 3 commits April 15, 2026 05:32
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
SeedDataset overrides the base YamlLoadable.from_yaml_file() with its
own implementation that was missing the empty-YAML guard, causing a
TypeError when yaml.safe_load() returns None.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@romanlutz romanlutz merged commit 9efcb6a into microsoft:main Apr 15, 2026
35 checks passed
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.

2 participants