microsoft/semantic-kernel · error · FunctionExecutionException

This `RestApiParameter` instance is frozen and cannot be mod

Error message

This `RestApiParameter` instance is frozen and cannot be modified.

What it means

A `RestApiParameter` raises `FunctionExecutionException` from `_throw_if_frozen` whenever any property setter runs after `freeze()` flipped `_is_frozen` to True. The OpenAPI plugin freezes parameters (transitively, when an operation is frozen) after a REST function is registered so that the function contract stays immutable at runtime. Mutating a parameter that is already part of a registered kernel function is treated as a contract violation.

Source

Thrown at python/semantic_kernel/connectors/openapi_plugin/models/rest_api_parameter.py:55

        self._type = type
        self._location = location
        self._style = style
        self._alternative_name = alternative_name
        self._description = description
        self._is_required = is_required
        self._default_value = default_value
        self._schema = schema
        self._response = response
        self._is_frozen = False

    def freeze(self):
        """Make the instance immutable."""
        self._is_frozen = True

    def _throw_if_frozen(self):
        """Raise an exception if the object is frozen."""
        if self._is_frozen:
            raise FunctionExecutionException("This `RestApiParameter` instance is frozen and cannot be modified.")

    @property
    def name(self):
        """Get the name of the parameter."""
        return self._name

    @name.setter
    def name(self, value: str):
        self._throw_if_frozen()
        self._name = value

    @property
    def type(self):
        """Get the type of the parameter."""
        return self._type

    @type.setter
    def type(self, value: str):

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Stop mutating the parameter after the operation is registered; if you must change it, do so before calling `create_functions_from_openapi` / before `freeze()`.
  2. Construct a fresh `RestApiParameter(...)` with the new values instead of editing an existing frozen instance.
  3. If you control the parsing pipeline, capture the operation objects before `operation.freeze()` is invoked and edit them in that window.
  4. Patch the source spec dict and re-run `create_functions_from_openapi` rather than editing parsed metadata post-registration.

Example fix

// before
kernel.add_openapi_plugin(...)
operation.parameters[0].name = "new_name"  # raises 1480

// after
# edit the parsed spec before registration
parsed_doc["paths"]["/x"]["get"]["parameters"][0]["name"] = "new_name"
kernel.add_openapi_plugin_from_spec(parsed_doc, ...)
Defensive patterns

Strategy: validation

Validate before calling

def assert_parameter_mutable(param) -> None:
    if getattr(param, "_is_frozen", False):
        raise RuntimeError(
            f"RestApiParameter '{param.name}' is frozen; build a new instance instead."
        )

# call before any setter
assert_parameter_mutable(operation.parameters[0])

Type guard

from typing import Protocol

def is_unfrozen_parameter(obj) -> bool:
    return hasattr(obj, "_is_frozen") and not obj._is_frozen

Try / catch

from semantic_kernel.exceptions import FunctionExecutionException

try:
    param.name = new_name
except FunctionExecutionException as e:
    if "frozen" in str(e):
        param = RestApiParameter(name=new_name, type=param.type, location=param.location)
    else:
        raise

Prevention

When it happens

Trigger: Calling any setter (e.g. `name`, `type`, `default_value`, `schema`, etc.) on a `RestApiParameter` whose owning `RestApiOperation.freeze()` has already been invoked. The freeze happens automatically inside `create_functions_from_openapi` (see `operation.freeze()` after registration) and in `RestApiPayload.freeze()` / `RestApiPayloadProperty.freeze()` cascades.

Common situations: Grabbing a parameter off a parsed operation and trying to tweak it after the operation was already registered into the kernel; reusing a frozen parameter object across multiple registration calls; writing tests that mutate parsed metadata after it has been turned into a `KernelFunction`.

Related errors


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