{"record":{"id":"e56eb4014b7a71e7","repo":"microsoft/semantic-kernel","slug":"the-restapioperation-instance-with-id-self-id","errorCode":null,"errorMessage":"The `RestApiOperation` instance with id {self.id} is frozen and cannot be modified.","messagePattern":"The `RestApiOperation` instance with id (.+?) is frozen and cannot be modified\\.","errorType":"exception","errorClass":"FunctionExecutionException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py","lineNumber":90,"sourceCode":"        self._request_body = request_body\n        self._responses = responses\n        self._security_requirements = security_requirements\n        self._is_frozen = False\n\n    def freeze(self):\n        \"\"\"Make the instance and its components immutable.\"\"\"\n        self._is_frozen = True\n\n        if self.request_body:\n            self.request_body.freeze()\n\n        for param in self.parameters:\n            param.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(\n                f\"The `RestApiOperation` instance with id {self.id} is frozen and cannot be modified.\"\n            )\n\n    @property\n    def id(self):\n        \"\"\"Get the ID of the operation.\"\"\"\n        return self._id\n\n    @id.setter\n    def id(self, value: str):\n        self._throw_if_frozen()\n        self._id = value\n\n    @property\n    def method(self):\n        \"\"\"Get the method of the operation.\"\"\"\n        return self._method\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py#L72-L108","documentation":"RestApiOperation implements a freeze pattern: once `freeze()` is called, the operation and its parameters/request body become immutable. Every property setter calls `_throw_if_frozen()`, which raises FunctionExecutionException if `_is_frozen` is True. This prevents modification of operations after they have been registered/validated, typically after an OpenAPI runner has loaded and prepared them for execution.","triggerScenarios":"Attempting to set any property (id, method, path, parameters, etc.) on a RestApiOperation after `freeze()` has been called on it. The OpenAPI runner freezes operations during preparation, so any post-load mutation triggers this.","commonSituations":"Developer loads an OpenAPI spec via the plugin, gets a handle to an operation object, and tries to modify its path or parameters at runtime. Attempting to reuse or reconfigure a frozen operation from a cached runner.","solutions":["Create a new RestApiOperation instance (or re-load the spec) instead of mutating a frozen one.","Perform all configuration before the operation is frozen (before the runner prepares/executes it).","Check `operation._is_frozen` before attempting mutation if you share operation handles across code paths."],"exampleFix":"// before\noperation.path = \"/new-path\"  # raises if frozen\n// after\n# build a new operation or re-load the spec with the desired path\nnew_op = RestApiOperation(id=operation.id, method=operation.method, path=\"/new-path\", ...)","handlingStrategy":"type-guard","validationCode":"def is_frozen(operation) -> bool:\n    return getattr(operation, \"_is_frozen\", False)","typeGuard":"def is_operation_frozen(op: RestApiOperation) -> bool:\n    \"\"\"Return True if the operation has been frozen and cannot be modified.\"\"\"\n    return op._is_frozen is True","tryCatchPattern":"try:\n    operation.path = new_path\nexcept FunctionExecutionException as e:\n    if \"frozen\" in str(e):\n        # create a new RestApiOperation instead of mutating\n        ...","preventionTips":["Treat loaded RestApiOperation instances as immutable after the runner prepares them.","Perform all configuration before calling freeze() or before runner execution.","Check _is_frozen before mutating if operation handles are shared."],"tags":["openapi","rest-api","immutability","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}