Skip to content

Better crash on None value for fields_to_overwrite_from_metadata#1159

Merged
jamesbraza merged 2 commits intomainfrom
fixing-crash-none
Oct 28, 2025
Merged

Better crash on None value for fields_to_overwrite_from_metadata#1159
jamesbraza merged 2 commits intomainfrom
fixing-crash-none

Conversation

@jamesbraza
Copy link
Copy Markdown
Collaborator

@jamesbraza jamesbraza commented Oct 28, 2025

Nice-ifying this error

@jamesbraza jamesbraza self-assigned this Oct 28, 2025
Copilot AI review requested due to automatic review settings October 28, 2025 00:15
@jamesbraza jamesbraza added the bug Something isn't working label Oct 28, 2025
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 28, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a TypeError crash that occurred when fields_to_overwrite_from_metadata was explicitly set to None. The fix ensures that a ValidationError is raised instead, providing clearer error handling.

Key changes:

  • Modified data.get() calls to use the or operator instead of providing a default value directly to get(), ensuring None values are properly handled
  • Added a test case to verify that ValidationError is raised when None is passed to fields_to_overwrite_from_metadata

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/paperqa/types.py Replaced data.get("fields_to_overwrite_from_metadata", DEFAULT_FIELDS_TO_OVERWRITE_FROM_METADATA) with data.get("fields_to_overwrite_from_metadata") or DEFAULT_FIELDS_TO_OVERWRITE_FROM_METADATA in four locations to properly handle None values
tests/test_paperqa.py Added test case to verify ValidationError is raised when fields_to_overwrite_from_metadata=None is passed to DocDetails

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dosubot
Copy link
Copy Markdown

dosubot bot commented Oct 28, 2025

Documentation Updates

Checked 1 published document(s). No updates required.

How did I do? Any feedback?  Join Discord

@jamesbraza jamesbraza changed the title Fixing TypeError crash on None value for fields_to_overwrite_from_metadata Better crash on None value for fields_to_overwrite_from_metadata Oct 28, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 28, 2025
@jamesbraza jamesbraza merged commit 3aa1b97 into main Oct 28, 2025
7 checks passed
@jamesbraza jamesbraza deleted the fixing-crash-none branch October 28, 2025 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants