{"record":{"id":"0b315a006c51ee55","repo":"redis/redis-py","slug":"maintenance-notifications-are-not-supported-for-co","errorCode":null,"errorMessage":"Maintenance notifications are not supported for connection class {connection_class_name}","messagePattern":"Maintenance notifications are not supported for connection class (.+?)","errorType":"exception","errorClass":"RedisError","httpStatus":null,"severity":"error","filePath":"redis/asyncio/connection.py","lineNumber":1929,"sourceCode":"        if maint_notifications_config and maint_notifications_config.enabled:\n            if not is_connection_supported:\n                if maint_notifications_config.enabled is True:\n                    # Unix sockets do not have a host endpoint for CLIENT\n                    # MAINT_NOTIFICATIONS to describe.\n                    if \"path\" in self.connection_kwargs:\n                        raise RedisError(\n                            \"Maintenance notifications are not supported for \"\n                            \"Unix domain socket connections\"\n                        )\n\n                    # Custom connection classes must inherit the async maintenance\n                    # mixin so handlers can update connection state safely.\n                    if not self._maintenance_notifications_connection_class_supported():\n                        connection_class = getattr(self, \"connection_class\", None)\n                        connection_class_name = getattr(\n                            connection_class, \"__name__\", connection_class\n                        )\n                        raise RedisError(\n                            \"Maintenance notifications are not supported for \"\n                            f\"connection class {connection_class_name}\"\n                        )\n\n                    # TCP-like connections still need a host to identify the\n                    # endpoint that can move during maintenance.\n                    raise RedisError(\n                        \"Maintenance notifications are not supported for connections \"\n                        \"without a host\"\n                    )\n                self._maint_notifications_pool_handler = None\n                self._oss_cluster_maint_notifications_handler = None\n                return\n\n            if not is_protocol_supported:\n                raise RedisError(\n                    \"Maintenance notifications handlers on connection are only supported with RESP version 3\"\n                )","sourceCodeStart":1911,"sourceCodeEnd":1947,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/asyncio/connection.py#L1911-L1947","documentation":"Raised as RedisError from the maintenance-notifications pool mixin when maintenance notifications are explicitly enabled but the connection class does not satisfy _maintenance_notifications_connection_class_supported(). Custom connection classes must inherit the async maintenance mixin so handlers can mutate connection state safely; otherwise the feature is refused at pool construction.","triggerScenarios":"Passing connection_class=MyCustomConnection (not derived from the supported async maintenance mixin) together with maint_notifications_config.enabled=True. Stock SSLConnection and TCP Connection are supported; arbitrary subclasses are not unless they opt in.","commonSituations":"Custom connection subclass for instrumentation/proxying that was not updated to inherit the maintenance mixin; feature flag rolled out to a code path that uses a bespoke connection class.","solutions":["Have your custom connection class inherit the async maintenance-notifications mixin (or whatever the project's supported base requires).","Disable maintenance notifications when using the custom class: maint_notifications_config=None.","Fall back to the stock connection class if maintenance notifications are more important than the customization."],"exampleFix":"// before\npool = ConnectionPool(connection_class=MyConn, maint_notifications_config=MaintNotificationsConfig(enabled=True))\n// after\nclass MyConn(MaintNotificationsMixin, SSLConnection): ...\npool = ConnectionPool(connection_class=MyConn, maint_notifications_config=MaintNotificationsConfig(enabled=True))","handlingStrategy":"validation","validationCode":"def connection_class_supports_maint(connection_class: type) -> bool:\n    # Custom classes must inherit the async maintenance mixin\n    from redis.asyncio.connection import AbstractConnection\n    maint_mixin_attrs = {'activate_maint_notifications_handling_if_enabled'}\n    return any(hasattr(b, attr) for b in connection_class.__mro__ for attr in maint_mixin_attrs)","typeGuard":"from redis.exceptions import RedisError\n\ndef is_unsupported_class_error(exc: BaseException) -> bool:\n    return isinstance(exc, RedisError) and 'connection class' in str(exc).lower() and 'Maintenance' in str(exc)","tryCatchPattern":"from redis.exceptions import RedisError\n\ntry:\n    pool = ConnectionPool(connection_class=MyConn, maint_notifications_config=cfg)\nexcept RedisError as e:\n    if 'connection class' in str(e):\n        pool = ConnectionPool(connection_class=MyConn)  # drop maint\n    else:\n        raise","preventionTips":["Inherit the maintenance mixin in custom connection classes that need the feature.","Disable maintenance notifications when using an unsupported custom class.","Run an integration test that constructs the pool with the real custom class."],"tags":["maintenance-notifications","connection-class","config","validation","async","pool","subclassing"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}