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
Property name conflicts with discriminator even when property is [JsonIgnore] #123431
When polymorphism is being used, if the type discriminator and a property on the C# type have the same name, even if that property is [JsonIgnore], deserialization fails.
Unhandled exception. System.InvalidOperationException: The type 'Derived' contains property 'type' that conflicts with an existing metadata property name. Consider either renaming it or ignoring it with JsonIgnoreAttribute.
at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_PropertyConflictsWithMetadataPropertyName(Type type, String propertyName)
at System.Text.Json.Serialization.Metadata.PolymorphicTypeResolver..ctor(JsonSerializerOptions options, JsonPolymorphismOptions polymorphismOptions, Type baseType, Boolean converterCanHaveMetadata)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo.Configure()
at System.Text.Json.Serialization.Metadata.JsonTypeInfo.<EnsureConfigured>g__ConfigureSynchronized|174_0()
at System.Text.Json.JsonSerializerOptions.GetTypeInfoInternal(Type type, Boolean ensureConfigured, Nullable`1 ensureNotNull, Boolean resolveIfMutable, Boolean fallBackToNearestAncestorType)
at System.Text.Json.JsonSerializerOptions.GetTypeInfoForRootType(Type type, Boolean fallBackToNearestAncestorType)
at System.Text.Json.JsonSerializer.GetTypeInfo[T](JsonSerializerOptions options)
at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
at Program.<Main>$(String[] args)
Regression?
No
Known Workarounds
No workarounds known, other than choosing a different C# property name.
Activity
dotnet-policy-service commentedon Jan 21, 2026
Tagging subscribers to this area: @dotnet/area-system-text-json
See info in area-owners.md if you want to be subscribed.
stephentoub commentedon Jan 21, 2026
I just realized this is another inheritance issue. If I put [JsonIgnore] on all the overrides, then it succeeds.
MihuBot commentedon Jan 21, 2026
I'm a bot. Here are possible related and/or duplicate issues (I may be wrong):