{"record":{"id":"62490788de43b385","repo":"microsoft/semantic-kernel","slug":"this-instance-is-frozen-and-cannot-be-modified","errorCode":null,"errorMessage":"This instance is frozen and cannot be modified.","messagePattern":"This 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_payload_property.py","lineNumber":42,"sourceCode":"        self._name = name\n        self._type = type\n        self._properties = properties or []\n        self._description = description\n        self._is_required = is_required\n        self._default_value = default_value\n        self._schema = schema\n        self._is_frozen = False\n\n    def freeze(self):\n        \"\"\"Make the instance immutable, and freeze nested properties.\"\"\"\n        self._is_frozen = True\n        for prop in self._properties:\n            prop.freeze()\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 instance is frozen and cannot be modified.\")\n\n    @property\n    def name(self):\n        \"\"\"Get the name of the property.\"\"\"\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 property.\"\"\"\n        return self._type\n\n    @type.setter\n    def type(self, value: str):","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/openapi_plugin/models/rest_api_payload_property.py#L24-L60","documentation":"`RestApiPayloadProperty._throw_if_frozen` raises `FunctionExecutionException` when a setter runs after `freeze()` marked the property (and its nested `_properties`) as immutable. The nested `for prop in self._properties: prop.freeze()` means an arbitrarily deep property tree is frozen top-down when the owning operation is frozen.","triggerScenarios":"Setting `name`, `type`, `description`, etc. on a payload property that lives under a payload/property whose owning operation has already been frozen. The freeze originates from `RestApiPayload.freeze()` which originates from `RestApiOperation.freeze()` during registration.","commonSituations":"Walking `operation.payload.properties` and renaming/retyping entries after the kernel function already exists; caching a parsed operation and mutating it for a second plugin; test fixtures that post-edit parsed trees.","solutions":["Edit the underlying OpenAPI spec and re-parse to get fresh, unfrozen properties.","Build a replacement `RestApiPayloadProperty(...)` and swap it in before `freeze()` runs.","Treat parsed operations as read-only after registration; do all transformation on the raw spec dict.","If you must reuse metadata, deep-copy the operation tree before any mutation."],"exampleFix":"// before\nprop = operation.payload.properties[0]\nprop.name = \"renamed\"  # raises 1482\n\n// after\nimport copy\nfresh = copy.deepcopy(operation)  # before freeze, or re-parse the spec\nfresh.payload.properties[0].name = \"renamed\"","handlingStrategy":"validation","validationCode":"def assert_property_mutable(prop) -> None:\n    if getattr(prop, \"_is_frozen\", False):\n        raise RuntimeError(f\"RestApiPayloadProperty '{prop.name}' is frozen.\")\n\nfor p in operation.payload.properties:\n    assert_property_mutable(p)","typeGuard":"def is_unfrozen_property(obj) -> bool:\n    return hasattr(obj, \"_is_frozen\") and not obj._is_frozen","tryCatchPattern":"from semantic_kernel.exceptions import FunctionExecutionException\n\ntry:\n    prop.name = renamed\nexcept FunctionExecutionException as e:\n    if \"frozen\" in str(e):\n        prop = RestApiPayloadProperty(name=renamed, type=prop.type)\n    else:\n        raise","preventionTips":["Walk payload trees read-only after registration.","Rename in the spec dict and re-parse for any change.","Use deep copies when reusing parsed objects.","Add a guard helper to your wrapper that blocks post-freeze edits."],"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"}