{"record":{"id":"8031004339dcb6f6","repo":"redis/redis-py","slug":"cannot-disable-maintenance-notifications-after-ena","errorCode":null,"errorMessage":"Cannot disable maintenance notifications after enabling them","messagePattern":"Cannot disable maintenance notifications after enabling them","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"redis/asyncio/connection.py","lineNumber":2051,"sourceCode":"    async def update_maint_notifications_config(\n        self,\n        maint_notifications_config: MaintNotificationsConfig,\n        oss_cluster_maint_notifications_handler: (\n            AsyncOSSMaintNotificationsHandler | None\n        ) = None,\n    ) -> None:\n        \"\"\"\n        Updates the maintenance notifications configuration.\n        This method should be called only if the pool was created\n        without enabling the maintenance notifications and\n        in a later point in time maintenance notifications\n        are requested to be enabled.\n        \"\"\"\n        if (\n            self.maint_notifications_enabled()\n            and not maint_notifications_config.enabled\n        ):\n            raise ValueError(\n                \"Cannot disable maintenance notifications after enabling them\"\n            )\n\n        if oss_cluster_maint_notifications_handler:\n            self._oss_cluster_maint_notifications_handler = (\n                oss_cluster_maint_notifications_handler\n            )\n            # OSS cluster mode and pool-handler mode are mutually exclusive\n            # (see __init__). A pool created with the default RESP3 \"auto\"\n            # config wires a pool handler before this method runs; clear it so\n            # new and existing connections are not configured with both handlers.\n            self._maint_notifications_pool_handler = None\n        else:\n            if (\n                maint_notifications_config.enabled\n                and not self._maintenance_notifications_supported()\n            ):\n                if maint_notifications_config.enabled is True:","sourceCodeStart":2033,"sourceCodeEnd":2069,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/asyncio/connection.py#L2033-L2069","documentation":"Maintenance notifications are a one-way switch on a pool: once enabled, per-connection handlers are wired into every connection's kwargs, and the pool refuses to reverse that by raising ValueError from update_maint_notifications_config. The guard at connection.py:2047-2051 keeps connection state consistent. To turn notifications off you must recreate the pool without them.","triggerScenarios":"Calling await pool.update_maint_notifications_config(MaintNotificationsConfig(enabled=False)) on a pool where maint_notifications_enabled() is already True.","commonSituations":"Runtime config reload that flips a feature flag off; generic enable/disable toggle code reused for the notifications feature; misunderstanding that enabling is irreversible on a given pool.","solutions":["Recreate the pool/client from scratch without maintenance notifications instead of trying to disable in place.","If you need both modes, keep two pools and route traffic to the right one.","Do not call update_maint_notifications_config with an enabled=False config on an already-enabled pool."],"exampleFix":"# before\nawait pool.update_maint_notifications_config(MaintNotificationsConfig(enabled=False))\n# after\nawait pool.aclose()\npool = ConnectionPool(host='redis.local', protocol=3)  # no maint config","handlingStrategy":"validation","validationCode":"if new_config.enabled is False and pool.maint_notifications_enabled():\n    # recreate the pool instead of disabling in place\n    raise ConfigError('Recreate the pool to disable maintenance notifications.')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat maintenance notifications as enable-only per pool lifecycle.","Drive the feature from immutable startup config rather than runtime toggles."],"tags":["config","maintenance-notifications","async"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}