Skip to content

fix: handle empty YAML and JSON config files#32

Merged
DarshanHarihar1 merged 1 commit into
mainfrom
cursor/fix-empty-config-file-9843
May 27, 2026
Merged

fix: handle empty YAML and JSON config files#32
DarshanHarihar1 merged 1 commit into
mainfrom
cursor/fix-empty-config-file-9843

Conversation

@DarshanHarihar1
Copy link
Copy Markdown
Contributor

Summary

Loading an empty justllms.yaml / justllms.yml or a JSON file containing only null caused Config.from_file() to crash with TypeError: argument after ** must be a mapping, not NoneType, because yaml.safe_load() and json.load() return None for those inputs.

This change treats null/empty documents as an empty configuration mapping (same as {}) and raises a clear ValueError when the top-level document is not a mapping (for example, a YAML list).

Changes

  • Config.from_file() now normalizes None to {} before constructing Config
  • Non-mapping top-level values raise ValueError with a descriptive message

Testing

Ran the full CI workflow locally:

  • ruff check justllms/
  • black --check justllms/
  • mypy justllms/ --ignore-missing-imports
  • python -m build + wheel import smoke test

Verified manually:

  • Empty .yaml → returns Config() with default empty providers
  • .json containing null → same behavior
  • YAML list at top level → ValueError
Open in Web Open in Cursor 

Empty config files make yaml.safe_load and json.load return None,
which caused Config.from_file to raise TypeError. Treat null/empty
documents as an empty mapping and reject non-mapping top-level values.

Co-authored-by: Darshan Harihar <DarshanHarihar1@users.noreply.github.com>
@github-actions github-actions Bot added bug Something isn't working llm provider size/XS labels May 27, 2026
@DarshanHarihar1 DarshanHarihar1 marked this pull request as ready for review May 27, 2026 18:06
@DarshanHarihar1 DarshanHarihar1 merged commit 02b342d into main May 27, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working llm provider size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants