{"id":"291124f02087d75b","repo":"redis/redis-py","slug":"method-is-not-supported-in-transactional-context","errorCode":null,"errorMessage":"Method is not supported in transactional context.","messagePattern":"Method is not supported in transactional context\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"redis/asyncio/cluster.py","lineNumber":3320,"sourceCode":"        for r, cmd in zip(responses, stack):\n            if isinstance(r, Exception):\n                self._annotate_exception(r, cmd.position + 1, cmd.args)\n\n                await record_operation_duration(\n                    command_name=\"TRANSACTION\",\n                    duration_seconds=time.monotonic() - start_time,\n                    server_address=self._transaction_connection.host,\n                    server_port=self._transaction_connection.port,\n                    db_namespace=str(self._transaction_connection.db),\n                    error=r,\n                )\n\n                raise r\n\n    def mset_nonatomic(\n        self, mapping: Mapping[AnyKeyT, EncodableT]\n    ) -> \"ClusterPipeline\":\n        raise NotImplementedError(\"Method is not supported in transactional context.\")\n\n    async def execute(\n        self, raise_on_error: bool = True, allow_redirections: bool = True\n    ) -> List[Any]:\n        stack = self._command_queue\n        if not stack and (not self._watching or not self._pipeline_slots):\n            return []\n\n        return await self._execute_transaction_with_retries(stack, raise_on_error)\n\n    async def _execute_transaction_with_retries(\n        self, stack: List[\"PipelineCommand\"], raise_on_error: bool\n    ):\n        return await self._retry.call_with_retry(\n            lambda: self._execute_transaction(stack, raise_on_error),\n            lambda error, failure_count: self._reinitialize_on_error(\n                error, failure_count\n            ),","sourceCodeStart":3302,"sourceCodeEnd":3338,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/asyncio/cluster.py#L3302-L3338","documentation":"Raised as NotImplementedError by ClusterPipeline.mset_nonatomic. The cluster pipeline is itself transactional (MULTI/EXEC on one node), so the non-atomic MSET helper — which fans out across slots as independent writes — has no meaningful implementation in this context.","triggerScenarios":"Calling await pipe.mset_nonatomic({...}) on a cluster pipeline object (the transactional pipeline returned by client.pipeline()).","commonSituations":"Reusing mset_nonatomic from the non-transactional ClusterPipeline API on a transactional pipeline, or copy-pasting code that worked on the async cluster client's pipeline() result.","solutions":["Call mset_nonatomic on the non-transactional cluster pipeline: client.pipeline(transaction=False) (or the regular client) instead of the transactional one.","Use plain mset() (with hash tags if needed) inside the transactional pipeline, or split the mapping into per-slot transactions.","If you need cross-slot non-atomic mset, use the async cluster client directly: await client.mset_nonatomic(mapping)."],"exampleFix":"// before\npipe = client.pipeline(transaction=True)\nawait pipe.mset_nonatomic(mapping)  # raises [85]\n// after\nawait client.mset_nonatomic(mapping)  # use the client, not the txn pipeline","handlingStrategy":"validation","validationCode":"if pipe._transaction:\n    raise ValueError('Use client.mset_nonatomic, not the transactional pipeline')","typeGuard":null,"tryCatchPattern":"try:\n    await pipe.mset_nonatomic(mapping)\nexcept NotImplementedError:\n    await client.mset_nonatomic(mapping)","preventionTips":["Use the cluster client (not the transactional pipeline) for mset_nonatomic.","Remember transactional cluster pipelines are single-node MULTI/EXEC."],"tags":["cluster","pipeline","mset","not-implemented"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}