{"id":"1f54eb43f1eaa145","repo":"redis/redis-py","slug":"maintenance-notifications-are-not-supported-by-thi","errorCode":null,"errorMessage":"Maintenance notifications are not supported by this connection type","messagePattern":"Maintenance notifications are not supported by this connection type","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"redis/connection.py","lineNumber":1968,"sourceCode":"\n    @property\n    def _maint_notifications_connection_handler(\n        self,\n    ) -> Optional[MaintNotificationsConnectionHandler]:\n        if isinstance(self._conn, MaintNotificationsAbstractConnection):\n            return self._conn._maint_notifications_connection_handler\n\n    @_maint_notifications_connection_handler.setter\n    def _maint_notifications_connection_handler(\n        self, value: Optional[MaintNotificationsConnectionHandler]\n    ):\n        self._conn._maint_notifications_connection_handler = value\n\n    def _get_socket(self) -> Optional[socket.socket]:\n        if isinstance(self._conn, MaintNotificationsAbstractConnection):\n            return self._conn._get_socket()\n        else:\n            raise NotImplementedError(\n                \"Maintenance notifications are not supported by this connection type\"\n            )\n\n    def _get_maint_notifications_connection_instance(\n        self, connection\n    ) -> MaintNotificationsAbstractConnection:\n        \"\"\"\n        Validate that connection instance supports maintenance notifications.\n        With this helper method we ensure that we are working\n        with the correct connection type.\n        After twe validate that connection instance supports maintenance notifications\n        we can safely return the connection instance\n        as MaintNotificationsAbstractConnection.\n        \"\"\"\n        if not isinstance(connection, MaintNotificationsAbstractConnection):\n            raise NotImplementedError(\n                \"Maintenance notifications are not supported by this connection type\"\n            )","sourceCodeStart":1950,"sourceCodeEnd":1986,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/connection.py#L1950-L1986","documentation":"Raised as a NotImplementedError in CacheProxyConnection._get_socket when the wrapped _conn is not an instance of MaintNotificationsAbstractConnection. The proxy delegates socket access only to connections that support maintenance notifications; a plain Connection lacks the maintenance plumbing and cannot expose its socket through this API.","triggerScenarios":"Calling getpeername/get_resolved_ip/maintenance-state accessors on a CacheProxyConnection whose underlying connection is a plain Connection (not maintenance-enabled). _get_socket checks isinstance(_conn, MaintNotificationsAbstractConnection) and raises otherwise.","commonSituations":"Wrapping a basic connection with the cache proxy and then invoking maintenance-notification APIs; mixing CSC with a connection type that was not built for maintenance notifications.","solutions":["Use a connection type that extends MaintNotificationsAbstractConnection when you need both CSC and maintenance APIs.","Avoid calling maintenance-notification accessors on connections that do not support them.","Check isinstance before calling, or disable maintenance-notification features for this connection."],"exampleFix":"// before\nsock = proxy_conn._get_socket()  # _conn is a plain Connection\n// after\n# use a maint-enabled connection type, or do not call _get_socket","handlingStrategy":"type-guard","validationCode":"from redis.maint_notifications import MaintNotificationsAbstractConnection\nif not isinstance(proxy_conn._conn, MaintNotificationsAbstractConnection):\n    raise NotImplementedError('Underlying connection does not support maintenance notifications')","typeGuard":"from redis.maint_notifications import MaintNotificationsAbstractConnection\ndef is_maint_capable(conn) -> bool:\n    return isinstance(getattr(conn, '_conn', conn), MaintNotificationsAbstractConnection)","tryCatchPattern":"try:\n    sock = proxy_conn._get_socket()\nexcept NotImplementedError:\n    # connection type lacks maintenance support; skip maintenance APIs\n    pass","preventionTips":["Only call maintenance-notification socket accessors on MaintNotificationsAbstractConnection instances.","Guard with isinstance before invoking maintenance APIs on proxied connections."],"tags":["maintenance-notifications","client-side-caching","connection-type"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}