{"id":"e783baa098b84f40","repo":"redis/redis-py","slug":"to-configure-maintenance-notifications-a-parser-m","errorCode":null,"errorMessage":"To configure maintenance notifications, a parser must be provided!","messagePattern":"To configure maintenance notifications, a parser must be provided!","errorType":"exception","errorClass":"RedisError","httpStatus":null,"severity":"error","filePath":"redis/asyncio/connection.py","lineNumber":245,"sourceCode":"        orig_host_address: str | None = None,\n        orig_socket_timeout: float | None = None,\n        orig_socket_connect_timeout: float | None = None,\n        oss_cluster_maint_notifications_handler: (\n            AsyncOSSMaintNotificationsHandler | None\n        ) = None,\n        parser: BaseParser | None = None,\n    ) -> None:\n        if (\n            not self.maint_notifications_config\n            or not self.maint_notifications_config.enabled\n        ):\n            self._maint_notifications_pool_handler = None\n            self._maint_notifications_connection_handler = None\n            self._oss_cluster_maint_notifications_handler = None\n            return\n\n        if not parser:\n            raise RedisError(\n                \"To configure maintenance notifications, a parser must be provided!\"\n            )\n\n        if not isinstance(parser, _AsyncHiredisParser) and not isinstance(\n            parser, _AsyncRESP3Parser\n        ):\n            raise RedisError(\n                \"Maintenance notifications are only supported with hiredis and RESP3 parsers!\"\n            )\n\n        if maint_notifications_pool_handler:\n            # Extract a reference to a new pool handler that copies all properties\n            # of the original one and has a different connection reference\n            # This is needed because when we attach the handler to the parser\n            # we need to make sure that the handler has a reference to the\n            # connection that the parser is attached to.\n            self._maint_notifications_pool_handler = (\n                maint_notifications_pool_handler.get_handler_for_connection()","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/asyncio/connection.py#L227-L263","documentation":"Raised by AbstractConnection._configure_maintenance_notifications when maintenance notifications are enabled but no parser argument was supplied to the method. The push handlers must be attached to a concrete parser instance; without one the library cannot wire up the notification callbacks.","triggerScenarios":"An internal/subclass call to _configure_maintenance_notifications that omits the parser= argument while maint_notifications_config.enabled is truthy. Not typically reachable through the public API unless a custom Connection subclass overrides connect() or disconnect()/reconnect wiring.","commonSituations":"Subclassing the async Connection and overriding the reconnect path while forgetting to forward parser=; calling internal hooks directly in tests or custom connection factories.","solutions":["If you subclass Connection, always forward the parser= argument into _configure_maintenance_notifications when maintenance notifications are enabled.","Use the public Redis()/from_url() constructors so the parser is wired automatically.","Disable maintenance notifications if you don't need them, to avoid the internal wiring path entirely."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# For Connection subclasses overriding the reconnect path:\nif self.maint_notifications_config.enabled and parser is None:\n    raise RuntimeError('parser= is required when maintenance notifications are enabled')","typeGuard":null,"tryCatchPattern":"from redis.exceptions import RedisError\ntry:\n    self._configure_maintenance_notifications(..., parser=parser)\nexcept RedisError as e:\n    if 'a parser must be provided' in str(e):\n        parser = self._get_parser(); self._configure_maintenance_notifications(..., parser=parser)","preventionTips":["Forward parser= into _configure_maintenance_notifications in subclasses.","Prefer the public constructors; don't call internal hooks directly."],"tags":["connection","maintenance-notifications","internal","subclassing"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}