Repository navigation
Improve exceptions for invalid elements in JSON entity collections - #39485
Merged
AndriySvyryd merged 1 commit intoNov 3, 2026
Merged
Conversation
- Throw a descriptive exception naming the entity type and navigation when a null element is encountered in MaterializeJsonEntityCollection - Throw a descriptive exception naming the entity type and navigation when a non-object element is encountered in MaterializeJsonEntityCollection - Add tests for both null and non-object elements in JSON entity collections Fixes dotnet#35863
Sean-mn
force-pushed
the
fix/json-collection-element-exceptions
branch
from
October 31, 2026 10:24
f7c0e3a to
292b4a4
Compare
Contributor
Author
|
@dotnet-policy-service agree |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, so the diagnostic, localization, API baseline, and functional test changes can proceed.
No open issues 🎉
1 file not reviewed
src/EFCore.Relational/Properties/RelationalStrings.Designer.cs: Generated file
What changed in this PR
This pull request improves diagnostics for invalid elements in relational JSON collections by distinguishing null and non-object values and identifying the affected type and property. It also adds localized resources, generated accessors, API baseline updates, and functional test coverage.
Changes:
- Added descriptive exceptions for
nulland non-object JSON collection elements. - Added localization resources, generated accessors, and API baseline entries.
- Added functional tests covering both invalid element cases.
- The diagnostics currently describe malformed complex-property collections as entity navigations and require correction.
This pull request requires changes.
| File | Description |
|---|---|
test/EFCore.Relational.Specification.Tests/Query/JsonQueryRelationalTestBase.cs |
Adds functional coverage for null and non-object JSON collection elements. |
src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.ClientMethods.cs |
Throws descriptive exceptions for invalid JSON collection elements. |
src/EFCore.Relational/Properties/RelationalStrings.resx |
Defines the new localized diagnostic messages. |
src/EFCore.Relational/Properties/RelationalStrings.Designer.cs |
Provides generated accessors for the new messages. |
src/EFCore.Relational/EFCore.Relational.baseline.json |
Records the added public resource methods in the API baseline. |
Review effort: Lite
AndriySvyryd
approved these changes
Nov 3, 2026
AndriySvyryd
left a comment
Member
There was a problem hiding this comment.
Thanks for your contribution!
Contributor
API review baseline changes for
|
6 tasks done
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.
Fixes #35863
Description
RelationalStrings.JsonEntityCollectionNullElement) when anullelement is encountered inMaterializeJsonEntityCollection.RelationalStrings.JsonEntityCollectionExpectedObject) when a non-object element is encountered inMaterializeJsonEntityCollection.JsonQueryRelationalTestBasecovering both cases.