You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Include propertyName when KeyNotFoundException is thrown in JsonElement.GetProperty #124956
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Text.Json.JsonElement.GetProperty(String propertyName)
at ...
Proposed behavior
Property name can be found in logs.
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. Property name is 'dateRange'.
at System.Text.Json.JsonElement.GetProperty(String propertyName)
at ...
Reasoning
When having chained methods sometimes it is hard to understand what property caused the issue.
Sample code:
// Strings.KeyNotFoundException = "The given key was not present in the dictionary. Property name is '{0}'."
throw new KeyNotFoundException(SR.Format(Strings.KeyNotFoundException, propertyName));
Activity
dotnet-policy-service commentedon Feb 27, 2026
Tagging subscribers to this area: @dotnet/area-system-text-json
See info in area-owners.md if you want to be subscribed.
Include propertyName in KeyNotFoundException thrown by JsonElement.Ge…