microsoft/semantic-kernel · error · KernelException

The value type '{value.PrimitiveType}' of {entityDescription

Error message

The value type '{value.PrimitiveType}' of {entityDescription} '{entityName}' is not supported.

What it means

GetParameterValue converts an OpenAPI default value (IOpenApiAny / IOpenApiPrimitive) into a .NET object. It handles Integer, Long, Float, Double, String, Byte, Binary, Boolean, Date, DateTime, Password; the switch default raises KernelException naming the primitive type that fell through. In practice the unhandled case is PrimitiveType.Null (and any future type), so a default value parsed as a null primitive triggers it.

Source

Thrown at dotnet/src/Functions/Functions.OpenApi/OpenApi/OpenApiDocumentParser.cs:595

        if (valueMetadata is not IOpenApiPrimitive value)
        {
            return null;
        }

        return value.PrimitiveType switch
        {
            PrimitiveType.Integer => ((OpenApiInteger)value).Value,
            PrimitiveType.Long => ((OpenApiLong)value).Value,
            PrimitiveType.Float => ((OpenApiFloat)value).Value,
            PrimitiveType.Double => ((OpenApiDouble)value).Value,
            PrimitiveType.String => ((OpenApiString)value).Value,
            PrimitiveType.Byte => ((OpenApiByte)value).Value,
            PrimitiveType.Binary => ((OpenApiBinary)value).Value,
            PrimitiveType.Boolean => ((OpenApiBoolean)value).Value,
            PrimitiveType.Date => ((OpenApiDate)value).Value,
            PrimitiveType.DateTime => ((OpenApiDateTime)value).Value,
            PrimitiveType.Password => ((OpenApiPassword)value).Value,
            _ => throw new KernelException($"The value type '{value.PrimitiveType}' of {entityDescription} '{entityName}' is not supported."),
        };
    }

    /// <summary>
    /// Asserts the successful reading of OpenAPI document.
    /// </summary>
    /// <param name="readResult">The reading results to be checked.</param>
    /// <param name="ignoreNonCompliantErrors">Flag indicating whether to ignore non-compliant errors.
    /// If set to true, the parser will not throw exceptions for non-compliant documents.
    /// Please note that enabling this option may result in incomplete or inaccurate parsing results.
    /// </param>
    private void AssertReadingSuccessful(ReadResult readResult, bool ignoreNonCompliantErrors)
    {
        if (readResult.OpenApiDiagnostic.Errors.Any())
        {
            var title = readResult.OpenApiDocument.Info?.Title;
            var errors = string.Join(";", readResult.OpenApiDiagnostic.Errors);

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Remove the 'default: null' (or replace with an actual value) from the offending property/parameter in the OpenAPI spec.
  2. If null is intended to mean 'no default', delete the default key entirely rather than setting it to null.
  3. Exclude the operation containing the property via OpenApiFunctionExecutionParameters.OperationsToExclude.
  4. In a fork, add a PrimitiveType.Null arm returning null in GetParameterValue.

Example fix

// before
//  properties:
//    nickname:
//      type: string
//      default: null
// after
//  properties:
//    nickname:
//      type: string
//      # no default key
Defensive patterns

Strategy: validation

Validate before calling

// Scan for 'default: null' (the typical trigger) or exotic primitives in the spec text/JSON.
using System.Text.Json.Nodes;
bool HasRiskyDefaults(JsonNode node)
{
    if (node is JsonObject o)
    {
        if (o.TryGetPropertyValue("default", out var d) && d is JsonValue v && v.TryGetValue<object>(out var val) && val is null)
            return true;
        foreach (var child in o.Values)
            if (child is not null && HasRiskyDefaults(child)) return true;
    }
    else if (node is JsonArray a)
        foreach (var item in a)
            if (item is not null && HasRiskyDefaults(item)) return true;
    return false;
}

Try / catch

try
{
    var plugin = await kernel.CreatePluginFromOpenApiAsync("api", specStream);
}
catch (KernelException ex) when (ex.Message.Contains("value type") && ex.Message.Contains("is not supported"))
{
    // the message names the primitive type and entity; remove that default from the spec and retry
}

Prevention

When it happens

Trigger: An OpenAPI schema property or parameter whose 'default' is explicitly JSON null, parsed by the OpenAPI reader as an OpenApiNull primitive (PrimitiveType.Null), which has no arm in the switch. Less commonly, a default expressed in a primitive form the reader maps to an exotic PrimitiveType.

Common situations: Specs generated by tools that emit 'default: null' (some Python/Spring generators do), specs hand-edited to set default: null to mean 'optional', or auto-generated specs that emit default values for enum/object-typed fields that the reader coerces into an unusual primitive.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/1834b320eca228a7. Report an issue: GitHub.