Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/7.0] Fix to #30028 - Added nullable property to Json mapped model resulting in errors instead of mapping non existing json property to null #30333

Merged
merged 1 commit into from
Mar 7, 2023

Conversation

maumar
Copy link
Contributor

@maumar maumar commented Feb 24, 2023

Ported from #30101
Fixes #30028

Description

Projecting or accessing into JSON object that has an optional subdocument that is missing (rather than being null) throws during query.

Customer impact

Customers are unable to query JSON objects when they are missing part of the document (which should be allowed when mapped using optional navigation). There is no good workaround, customers need to edit JSON and add the missing element(s). Also, we already patched similar issue, when the "leaf" property was missing rather than navigation - see #29219

How found

Multiple customer reports on 7.0.

Regression

No. JSON support has been introduced in 7.0.

Testing

Added regression tests.

Risk

Low-Mid; Fix is relatively small and involves hand-crafting expression call to TryGetValue() rather than GetValue() that we used before. Additional risk comes from the fact that the change is in common code path. It gets used every time JSON is mapped to entities that are nested (e.g. Customer entity having Details entity mapped to JSON, and Details entity itself has a sub-entity Address mapped to the same JSON). Added quirk to revert to old behavior if necessary.

…g in errors instead of mapping non existing json property to null

Problem was that we when accessing inner property on a JsonElement we used GetProperty. If property is not present (which should be allowed if we try to access optional navigation) KeyNotFound is thrown.

Fix is to use TryGetProperty instead to gracefully handle this scenario.

Fixes #30028
@ajcvickers ajcvickers added this to the 7.0.x milestone Feb 25, 2023
@rbhanda rbhanda modified the milestones: 7.0.x, 7.0.5 Feb 28, 2023
@wtgodbe wtgodbe merged commit c56c531 into release/7.0 Mar 7, 2023
@wtgodbe wtgodbe deleted the fix30028_70 branch March 7, 2023 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants