{"record":{"id":"309af271569d823e","repo":"microsoft/semantic-kernel","slug":"this-restapiparameter-instance-is-frozen-and-can","errorCode":null,"errorMessage":"This `RestApiParameter` instance is frozen and cannot be modified.","messagePattern":"This `RestApiParameter` instance is frozen and cannot be modified\\.","errorType":"exception","errorClass":"FunctionExecutionException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/openapi_plugin/models/rest_api_parameter.py","lineNumber":55,"sourceCode":"        self._type = type\n        self._location = location\n        self._style = style\n        self._alternative_name = alternative_name\n        self._description = description\n        self._is_required = is_required\n        self._default_value = default_value\n        self._schema = schema\n        self._response = response\n        self._is_frozen = False\n\n    def freeze(self):\n        \"\"\"Make the instance immutable.\"\"\"\n        self._is_frozen = True\n\n    def _throw_if_frozen(self):\n        \"\"\"Raise an exception if the object is frozen.\"\"\"\n        if self._is_frozen:\n            raise FunctionExecutionException(\"This `RestApiParameter` instance is frozen and cannot be modified.\")\n\n    @property\n    def name(self):\n        \"\"\"Get the name of the parameter.\"\"\"\n        return self._name\n\n    @name.setter\n    def name(self, value: str):\n        self._throw_if_frozen()\n        self._name = value\n\n    @property\n    def type(self):\n        \"\"\"Get the type of the parameter.\"\"\"\n        return self._type\n\n    @type.setter\n    def type(self, value: str):","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/openapi_plugin/models/rest_api_parameter.py#L37-L73","documentation":"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.","triggerScenarios":"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.","commonSituations":"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`.","solutions":["Stop mutating the parameter after the operation is registered; if you must change it, do so before calling `create_functions_from_openapi` / before `freeze()`.","Construct a fresh `RestApiParameter(...)` with the new values instead of editing an existing frozen instance.","If you control the parsing pipeline, capture the operation objects before `operation.freeze()` is invoked and edit them in that window.","Patch the source spec dict and re-run `create_functions_from_openapi` rather than editing parsed metadata post-registration."],"exampleFix":"// before\nkernel.add_openapi_plugin(...)\noperation.parameters[0].name = \"new_name\"  # raises 1480\n\n// after\n# edit the parsed spec before registration\nparsed_doc[\"paths\"][\"/x\"][\"get\"][\"parameters\"][0][\"name\"] = \"new_name\"\nkernel.add_openapi_plugin_from_spec(parsed_doc, ...)","handlingStrategy":"validation","validationCode":"def assert_parameter_mutable(param) -> None:\n    if getattr(param, \"_is_frozen\", False):\n        raise RuntimeError(\n            f\"RestApiParameter '{param.name}' is frozen; build a new instance instead.\"\n        )\n\n# call before any setter\nassert_parameter_mutable(operation.parameters[0])","typeGuard":"from typing import Protocol\n\ndef is_unfrozen_parameter(obj) -> bool:\n    return hasattr(obj, \"_is_frozen\") and not obj._is_frozen","tryCatchPattern":"from semantic_kernel.exceptions import FunctionExecutionException\n\ntry:\n    param.name = new_name\nexcept FunctionExecutionException as e:\n    if \"frozen\" in str(e):\n        param = RestApiParameter(name=new_name, type=param.type, location=param.location)\n    else:\n        raise","preventionTips":["Treat parsed RestApiOperation trees as read-only after registration.","Do all metadata mutation on the raw spec dict and re-parse.","Deep-copy operations if you need to reuse and mutate them.","Keep a unit test that asserts your wrapper never touches frozen metadata."],"tags":["openapi-plugin","immutability","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}