microsoft/semantic-kernel · error · PluginInitializationError

Parameter {name} cannot have a 'content' field. Expected: sc

Error message

Parameter {name} cannot have a 'content' field. Expected: schema.

What it means

Per OpenAPI, a parameter's `schema` and `content` are mutually exclusive. `_parse_parameters` explicitly rejects parameters that carry a `content` field and raises `PluginInitializationError`. The connector only consumes the `schema` form; `content`-based parameters are not supported.

Source

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

        """
        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"},
                )
            )
        return result

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Rewrite the parameter to use `schema` instead of `content`.
  2. If the value truly needs media-type serialization unsupported here, model it as a request body instead of a parameter.
  3. Validate the spec with `openapi-spec-validator` to catch mutually-exclusive fields.
  4. If you do not control the spec, pre-process it to convert `content` parameters to `schema` form before passing to the kernel.

Example fix

# before
parameters:
  - name: filter
    in: query
    content:
      application/json: { schema: { type: object } }   # raises 1490

# after
parameters:
  - name: filter
    in: query
    schema: { type: object }
Defensive patterns

Strategy: validation

Validate before calling

def reject_content_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 "content" in p:
                    problems.append(f"{method} {path}: param '{p.get('name')}' uses 'content'")
    return problems

problems = reject_content_parameters(spec)
assert not problems, problems

Type guard

def uses_schema_not_content(p) -> bool:
    return isinstance(p, dict) and "schema" in p and "content" not in p

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 "'content' field" in str(e):
        # convert content -> schema in the spec, then retry
        raise
    raise

Prevention

When it happens

Trigger: A parameter object in the spec that defines serialization via `content` (media-type-keyed) instead of `schema`. The error names the parameter and fires during parsing.

Common situations: Specs autogenerated from tools that prefer `content`; complex serialization (e.g. binary/multipart) modeled via `content`; hand-authored specs mixing both styles; specs targeting clients that accept `content` but not this connector.

Related errors


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