microsoft/semantic-kernel · error · PluginInitializationError

Parameter {name} is missing 'in' field

Error message

Parameter {name} is missing 'in' field

What it means

`OpenApiParser._parse_parameters` requires every OpenAPI parameter object to have an `in` field. If `param.get("in")` is falsy, it raises `PluginInitializationError` naming the parameter. Per the OpenAPI spec, `in` (query/header/path/cookie) is a required field of a parameter object.

Source

Thrown at python/semantic_kernel/connectors/openapi_plugin/openapi_parser.py:79

                local files.
            enable_http_ref_resolution: Whether to resolve external HTTP $ref references.
                Disabled by default.
        """
        resolve_types = RESOLVE_INTERNAL
        if enable_file_ref_resolution:
            resolve_types |= RESOLVE_FILES
        if enable_http_ref_resolution:
            resolve_types |= RESOLVE_HTTP
        parser = ResolvingParser(openapi_document, resolve_types=resolve_types)
        return parser.specification

    def _parse_parameters(self, parameters: list[dict[str, Any]]):
        """Parse the parameters from the OpenAPI document."""
        result: list[RestApiParameter] = []
        for param in parameters:
            name: str = param["name"]
            if not param.get("in"):
                raise PluginInitializationError(f"Parameter {name} is missing 'in' field")
            if param.get("content", None) is not None:
                # The schema and content fields are mutually exclusive.
                raise PluginInitializationError(f"Parameter {name} cannot have a 'content' field. Expected: schema.")
            location = RestApiParameterLocation(param["in"])
            description: str | None = param.get("description", None)
            is_required: bool = param.get("required", False)
            default_value = param.get("default", None)
            schema: dict[str, Any] | None = param.get("schema", None)

            result.append(
                RestApiParameter(
                    name=name,
                    type=schema.get("type", "string") if schema else "string",
                    location=location,
                    description=description,
                    is_required=is_required,
                    default_value=default_value,
                    schema=schema if schema else {"type": "string"},

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Add the required `in` field to the offending parameter in the spec (`query`, `header`, `path`, or `cookie`).
  2. Run the spec through a linter (`openapi-spec-validator`, `spectral`) before loading it.
  3. If the parameter is invalid, remove it from the spec.
  4. Pin/upgrade the spec to OpenAPI 3.0+ semantics and re-validate.

Example fix

# before
parameters:
  - name: petId
    schema: { type: integer }   # missing 'in' -> raises 1489

# after
parameters:
  - name: petId
    in: path
    required: true
    schema: { type: integer }
Defensive patterns

Strategy: validation

Validate before calling

def validate_parameters(spec) -> list[str]:
    problems = []
    for path, methods in spec.get("paths", {}).items():
        for method, details in methods.items():
            for p in details.get("parameters", []):
                if not p.get("in"):
                    problems.append(f"{method} {path}: param '{p.get('name')}' missing 'in'")
    return problems

problems = validate_parameters(spec)
assert not problems, problems

Type guard

def is_valid_openapi_parameter(p) -> bool:
    return isinstance(p, dict) and bool(p.get("name")) and bool(p.get("in"))

Try / catch

from semantic_kernel.exceptions import PluginInitializationError

try:
    kernel.add_openapi_plugin(plugin_name="x", openapi_parsed_spec=spec)
except PluginInitializationError as e:
    if "missing 'in' field" in str(e):
        # patch the spec and retry
        raise
    raise

Prevention

When it happens

Trigger: An OpenAPI parameter object in `paths.*.parameters` or `components.parameters` that is missing the `in` key, or has it set to an empty string. The error fires during parsing/registration of the plugin.

Common situations: Hand-edited specs that forgot `in`; a code-generated spec with a bug; a parameter defined only by `{"name": "x", "schema": {...}}`; refactoring that stripped the field; specs authored against a different (older/newer) OpenAPI version.

Related errors


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