{"record":{"id":"b0de35118f32cd1f","repo":"python-telegram-bot/python-telegram-bot","slug":"you-can-not-assign-a-new-value-to-fallbacks-after","errorCode":null,"errorMessage":"You can not assign a new value to fallbacks after initialization.","messagePattern":"You can not assign a new value to fallbacks after initialization\\.","errorType":"validation","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"src/telegram/ext/_handlers/conversationhandler.py","lineNumber":487,"sourceCode":"        associated :obj:`BaseHandler` objects that should be used in that state.\n        \"\"\"\n        return self._states\n\n    @states.setter\n    def states(self, _: object) -> NoReturn:\n        raise AttributeError(\"You can not assign a new value to states after initialization.\")\n\n    @property\n    def fallbacks(self) -> list[BaseHandler[Update, CCT, object]]:\n        \"\"\"list[:class:`telegram.ext.BaseHandler`]: A list of handlers that might be used if\n        the user is in a conversation, but every handler for their current state returned\n        :obj:`False` on :meth:`check_update`.\n        \"\"\"\n        return self._fallbacks\n\n    @fallbacks.setter\n    def fallbacks(self, _: object) -> NoReturn:\n        raise AttributeError(\"You can not assign a new value to fallbacks after initialization.\")\n\n    @property\n    def allow_reentry(self) -> bool:\n        \"\"\":obj:`bool`: Determines if a user can restart a conversation with an entry point.\"\"\"\n        return self._allow_reentry\n\n    @allow_reentry.setter\n    def allow_reentry(self, _: object) -> NoReturn:\n        raise AttributeError(\n            \"You can not assign a new value to allow_reentry after initialization.\"\n        )\n\n    @property\n    def per_user(self) -> bool:\n        \"\"\":obj:`bool`: If the conversation key should contain the User's ID.\"\"\"\n        return self._per_user\n\n    @per_user.setter","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/python-telegram-bot/python-telegram-bot/blob/d3b69d2e9fb7af6c796f84516cfda751752c7cb7/src/telegram/ext/_handlers/conversationhandler.py#L469-L505","documentation":"ConversationHandler.fallbacks is read-only after initialization; assigning handler.fallbacks = [...] raises AttributeError. The fallback handler list is fixed in _fallbacks at construction time.","triggerScenarios":"handler.fallbacks = [CommandHandler('cancel', cancel_cb)] on an existing instance.","commonSituations":"Deciding to add a cancel/stop command after handler construction, or configuration-driven bot setups that try to patch handlers after registration.","solutions":["Include all fallbacks in the constructor's fallbacks list","Rebuild the ConversationHandler and re-register it if fallbacks must change"],"exampleFix":"# before\nconv.fallbacks = [CommandHandler('cancel', cancel)]  # raises\n# after\nconv = ConversationHandler(entry, states, [CommandHandler('cancel', cancel)])","handlingStrategy":"type-guard","validationCode":"def build(entry, states, fallbacks, **kw):\n    return ConversationHandler(entry, states, fallbacks, **kw)","typeGuard":null,"tryCatchPattern":"try:\n    conv.fallbacks = [fb]\nexcept AttributeError:\n    conv = ConversationHandler(conv.entry_points, conv.states, [fb])","preventionTips":["Declare all fallbacks up front","Rebuild handler if fallback list changes"],"tags":["python","telegram-bot","conversation-handler","immutable-property","fallbacks"],"backgroundTag":"read-only-property-assignment","analyzedSha":"d3b69d2e9fb7af6c796f84516cfda751752c7cb7","analyzedAt":"2026-08-28T16:18:54.805Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}