Skip to content

Use "Invalid value" for Literal validation errors - #1329

Open
Brohammad wants to merge 2 commits into
msgspec:mainfrom
Brohammad:fix-literal-validation-error-message
Open

Brohammad wants to merge 2 commits into
msgspec:mainfrom
Brohammad:fix-literal-validation-error-message

Conversation

@Brohammad

Copy link
Copy Markdown

Summary

  • Report Invalid value %R instead of Invalid enum value %R when a typing.Literal lookup fails
  • Keep Invalid enum value for real enum.Enum / IntEnum types (lookup->cls != NULL)
  • Apply the same wording to bool-literal validation paths (json, msgpack, convert)

Fixes #1009

Test plan

  • Updated Literal tests in test_json.py, test_convert.py, test_common.py, test_msgpack.py, test_schema.py
  • Enum error messages unchanged (Invalid enum value 2 for enum.Enum)
  • Literal-related tests pass locally

Literal lookup failures previously reused the enum error wording.
Differentiate in _Lookup_OnMissing and bool-literal paths so enums
still report "Invalid enum value" while Literal uses "Invalid value".

Fixes msgspec#1009
Copilot AI balanced review requested due to automatic review settings November 7, 2026 14:45
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-07T14:45:12.585746Z
We couldn’t complete this review. Comment @codex review to try again.
8eb4a2e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@Brohammad Brohammad left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

pls do let me know if there is any issue with the pr @admins

This branch has not been deployed

No deployments
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.

Validation errors for Literal types incorrectly say 'enum value'

2 participants