Repository navigation
Throw for invalid string values of unsigned enums in JSON - #39068
Merged
AndriySvyryd merged 1 commit intoSep 22, 2026
Merged
Conversation
JsonWarningEnumReaderWriter inverted the ulong.TryParse check for enums with an unsigned underlying type, so a string that is neither a member name nor a number was silently materialized as the default value instead of throwing BadEnumValue like it does for signed enums. Co-Authored-By: Claude Fable 5.1 <[email protected]>
AndriySvyryd
approved these changes
Sep 22, 2026
AndriySvyryd
left a comment
Member
There was a problem hiding this comment.
Thanks for your contribution!
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The change and regression coverage address the invalid unsigned-enum behavior with no unresolved blocking issues.
Review effort: Lite
Findings: None
What changed in this PR
This pull request fixes invalid unsigned enum string values in JSON parsing so they throw BadEnumValue instead of becoming the default value.
Changes:
- Corrects the
ulong.TryParsecondition. - Adds regression coverage for valid and invalid enum strings.
| File | Description |
|---|---|
test/EFCore.Tests/Storage/Json/JsonWarningEnumReaderWriterTest.cs |
Adds regression tests for enum parsing. |
src/EFCore/Storage/Json/JsonWarningEnumReaderWriter.cs |
Fixes unsigned enum parsing fallback behavior. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JsonWarningEnumReaderWriter inverted the ulong.TryParse check for enums with an unsigned underlying type, so a string that is neither a member name nor a number was silently materialized as the default value instead of throwing BadEnumValue like it does for signed enums.