{"record":{"id":"b35485010746754c","repo":"redis/redis-py","slug":"himport-is-not-supported-on-the-multi-database-ac","errorCode":null,"errorMessage":"HIMPORT is not supported on the multi-database (Active-Active) client","messagePattern":"HIMPORT is not supported on the multi-database \\(Active-Active\\) client","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/asyncio/multidb/client.py","lineNumber":307,"sourceCode":"        \"\"\"\n        if not self.initialized:\n            await self.initialize()\n\n        return await self.command_executor.execute_command(*args, **options)\n\n    # HIMPORT is not supported on the multi-database client. A HIMPORT fieldset is\n    # per-connection server session state tracked by a single client's registry;\n    # there is no coherent way to keep that state consistent across independent\n    # database clients through failover. ``himport_set`` is inherited from\n    # ``AsyncCoreCommands`` (and the lifecycle methods would otherwise be missing\n    # entirely), so override them to fail early and clearly instead of surfacing a\n    # confusing ``no such fieldset`` at runtime.\n    _HIMPORT_UNSUPPORTED = (\n        \"HIMPORT is not supported on the multi-database (Active-Active) client\"\n    )\n\n    async def himport_prepare(self, *args: Any, **kwargs: Any) -> Any:\n        raise DataError(self._HIMPORT_UNSUPPORTED)\n\n    async def himport_set(self, *args: Any, **kwargs: Any) -> Any:\n        raise DataError(self._HIMPORT_UNSUPPORTED)\n\n    async def himport_discard(self, *args: Any, **kwargs: Any) -> Any:\n        raise DataError(self._HIMPORT_UNSUPPORTED)\n\n    async def himport_discard_all(self, *args: Any, **kwargs: Any) -> Any:\n        raise DataError(self._HIMPORT_UNSUPPORTED)\n\n    def pipeline(self):\n        \"\"\"\n        Enters into pipeline mode of the client.\n        \"\"\"\n        return Pipeline(self)\n\n    async def transaction(\n        self,","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/asyncio/multidb/client.py#L289-L325","documentation":"Raised as DataError by MultiDBClient.himport_prepare(). HIMPORT tracks per-connection server-side fieldset state that cannot be kept coherent across independent database clients during geographic failover, so the multi-database client deliberately disables all HIMPORT lifecycle methods rather than silently losing state. It fails fast at call time instead of producing a confusing server-side 'no such fieldset' later.","triggerScenarios":"Calling await client.himport_prepare(...) (or, via the inherited AsyncCoreCommands surface, anything that resolves to HIMPORT PREPARE) on a MultiDBClient instance. The override at client.py:306-307 unconditionally raises before any wire traffic.","commonSituations":"Porting code from a plain redis.asyncio.Redis client to MultiDBClient for Active-Active failover without removing HIMPORT usage; IDE autocompletion suggesting himport_* because they are inherited from AsyncCoreCommands.","solutions":["Do not use HIMPORT with the multi-database client; restructure the workload to use commands whose state is key-scoped (HSET, HGETDEL, etc.).","If you genuinely need HIMPORT, bypass MultiDBClient and operate on a single underlying redis.asyncio.Redis client directly.","Grep your codebase for himport_prepare/himport_set/himport_discard/himport_discard_all before migrating to MultiDBClient.","Track this as a known unsupported surface in your client wrapper so callers get a typed error early."],"exampleFix":"// before\nfs = await client.himport_prepare(\"myset\")  # DataError on MultiDBClient\n\n// after - use key-scoped hashes instead\nawait client.hset(\"myhash\", mapping={\"f1\": \"v1\"})","handlingStrategy":"type-guard","validationCode":"def supports_himport(client) -> bool:\n    # MultiDBClient (and its Pipeline) override the himport_* methods to raise\n    return type(client).__name__ != \"MultiDBClient\"\n\nif supports_himport(client):\n    await client.himport_prepare(\"myset\")\nelse:\n    raise NotImplementedError(\"HIMPORT is not supported on the multi-database client\")","typeGuard":"from redis.asyncio.multidb.client import MultiDBClient\n\ndef is_multidb_client(client) -> bool:\n    return isinstance(client, MultiDBClient)","tryCatchPattern":"from redis.exceptions import DataError\n\ntry:\n    await client.himport_prepare(\"myset\")\nexcept DataError as e:\n    if \"HIMPORT is not supported\" in str(e):\n        # fall back to key-scoped hash commands\n        await client.hset(\"myhash\", mapping=mapping)\n    else:\n        raise","preventionTips":["Grep for himport_prepare/himport_set/himport_discard/himport_discard_all before adopting MultiDBClient.","Gate HIMPORT code paths behind a client-capability check.","Keep HIMPORT usage on a dedicated single redis.asyncio.Redis connection.","Document HIMPORT as unsupported in your service's client wrapper."],"tags":["multidb","himport","unsupported","dataerror","validation"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}