microsoft/semantic-kernel · error · KernelException

Parameter location of {parameter.Name} parameter of {operati

Error message

Parameter location of {parameter.Name} parameter of {operationId} operation is undefined.

What it means

Thrown by CreateRestApiOperationParameters when an OpenAPI parameter's 'in' field (path/query/header/cookie) is null. The 'in' field is required by the OpenAPI spec for every parameter, so a null value means the document is non-compliant or was authored incorrectly; SK refuses to guess the location.

Source

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

        return result;
    }

    /// <summary>
    /// Creates REST API parameters.
    /// </summary>
    /// <param name="operationId">The operation id.</param>
    /// <param name="parameters">The OpenAPI parameters.</param>
    /// <returns>The parameters.</returns>
    private static List<RestApiParameter> CreateRestApiOperationParameters(string operationId, IEnumerable<OpenApiParameter> parameters)
    {
        var result = new List<RestApiParameter>();

        foreach (var parameter in parameters)
        {
            if (parameter.In is null)
            {
                throw new KernelException($"Parameter location of {parameter.Name} parameter of {operationId} operation is undefined.");
            }

            if (parameter.Style is null)
            {
                throw new KernelException($"Parameter style of {parameter.Name} parameter of {operationId} operation is undefined.");
            }

            var restParameter = new RestApiParameter(
                parameter.Name,
                parameter.Schema.Type,
                parameter.Required,
                parameter.Explode,
                (RestApiParameterLocation)Enum.Parse(typeof(RestApiParameterLocation), parameter.In.ToString()!),
                (RestApiParameterStyle)Enum.Parse(typeof(RestApiParameterStyle), parameter.Style.ToString()!),
                parameter.Schema.Items?.Type,
                GetParameterValue(parameter.Schema.Default, "parameter", parameter.Name),
                parameter.Description,
                parameter.Schema.Format,

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Open the spec and add the missing 'in' field to the named parameter (one of path, query, header, cookie).
  2. Run the spec through Swagger Editor / spectral to surface parameters missing required fields.
  3. Regenerate the spec from the source if it was produced by a converter that lost the 'in' value.
  4. Remove the malformed parameter if it is not actually needed.

Example fix

// before - parameter missing 'in'
{ "name": "userId", "required": true, "schema": { "type": "string" } }

// after - location specified
{ "name": "userId", "in": "path", "required": true, "schema": { "type": "string" } }
Defensive patterns

Strategy: validation

Validate before calling

foreach (var (path, item) in doc.Paths)
    foreach (var p in item.Operations.SelectMany(kv => kv.Value.Parameters))
        if (p.In is null)
            throw new InvalidDataException($"Parameter '{p.Name}' on {path} is missing 'in'.");

Type guard

static bool AllParametersHaveLocation(OpenApiDocument doc)
    => doc.Paths.SelectMany(p => p.Value.Operations.SelectMany(o => o.Value.Parameters)).All(p => p.In is not null);

Prevention

When it happens

Trigger: A parameter object in the spec that omits the 'in' property entirely, or a malformed parameter where the reader left In as null. Because the code immediately casts parameter.In to a RestApiParameterLocation enum, a null would also risk a NullReferenceException, so this guard fails fast with a clear message instead.

Common situations: A hand-authored spec missing the 'in' field on a parameter; a converted/generated spec that dropped the location; a parameter defined at the wrong level (e.g. a request-body field mislabeled as a parameter).

Related errors


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