.Net: fix: prevent duplicate "null" in JSON Schema type arrays for nullable parameters by roli-lpci · Pull Request #13635 · microsoft/semantic-kernel
… parameters
InsertNullTypeIfRequired() uses jsonArray.Contains(NullType) to check
for existing "null" entries before adding one. JsonArray.Contains()
compares JsonNode objects by reference equality — JsonNode does not
override Equals(). The NullType constant ("null") creates a new
JsonNode on implicit conversion, so the guard always fails and "null"
is always added as a duplicate.
This produces invalid schemas like ["string", "null", "null"] for
Nullable<T> parameters with = null defaults, causing HTTP 400 from
OpenAI's strict-mode API.
The fix replaces .Contains() with a value-based .Any() check, following
the existing pattern used in NormalizeAdditionalProperties in the same
file.
Fixes microsoft#13527
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Issue or Pull requests regarding .NET code
Issues or pull requests impacting the core kernel
labels
Mar 5, 2026
github-actions
bot
changed the title
fix: prevent duplicate "null" in JSON Schema type arrays for nullable parameters
.Net: fix: prevent duplicate "null" in JSON Schema type arrays for nullable parameters
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