{"record":{"id":"c198883817a33c79","repo":"redis/redis-py","slug":"to-configure-maintenance-notifications-a-parser-m-c19888","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/connection.py","lineNumber":486,"sourceCode":"        parser: Optional[BaseParser] = None,\n    ):\n        \"\"\"\n        Enable maintenance notifications by setting up\n        handlers and storing original connection parameters.\n\n        Should be used ONLY with parsers that support push notifications.\n        \"\"\"\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, _HiredisParser) and not isinstance(\n            parser, _RESP3Parser\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":468,"sourceCodeEnd":504,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/connection.py#L468-L504","documentation":"Raised by AbstractConnection._configure_maintenance_notifications() when maintenance notifications are enabled in config but no parser argument was passed to the method. The push-notification setup needs an existing parser instance to wire up notification reading; a missing parser is treated as an internal wiring error.","triggerScenarios":"Calling _configure_maintenance_notifications(...) with maint_notifications_config.enabled=True but parser=None. This is generally an internal/library-side wiring path rather than a normal user API.","commonSituations":"Subclassing or monkey-patching the connection and overriding the maintenance-notification setup without forwarding a parser. Internal code paths that build a connection with maint notifications but forget to pass the parser.","solutions":["Pass a valid parser instance (the connection's parser) when calling _configure_maintenance_notifications.","Ensure maint_notifications_config.enabled is False unless your setup supplies a parser.","If you are not intentionally using maintenance notifications, leave them disabled."],"exampleFix":"// before\nconn._configure_maintenance_notifications(\n    maint_notifications_pool_handler=handler,\n    parser=None,\n)\n// after\nconn._configure_maintenance_notifications(\n    maint_notifications_pool_handler=handler,\n    parser=conn._get_parser(),\n)","handlingStrategy":"validation","validationCode":"if conn.maint_notifications_config and conn.maint_notifications_config.enabled:\n    parser = conn._get_parser()\n    assert parser is not None, 'parser required for maint notifications'\nconn._configure_maintenance_notifications(parser=parser)","typeGuard":"from redis.connection import BaseParser\n\ndef has_parser(parser) -> bool:\n    return parser is not None and isinstance(parser, BaseParser)","tryCatchPattern":"try:\n    conn._configure_maintenance_notifications(parser=parser)\nexcept RedisError:\n    conn._configure_maintenance_notifications(parser=conn._get_parser())","preventionTips":["Always forward the connection's parser when wiring maintenance notifications.","Disable maint notifications in configs that cannot supply a parser."],"tags":["connection","maintenance-notifications","parser","internal"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}