Skip to content

[BUG] Updated user data of a different user is not propagated to persistence #3601

@nikhilweee

Description

@nikhilweee

Steps to Reproduce

async def callback(update, context):
  # current_user_id = update.effective_user.id
  # other_user_id = httpx.get("network/call")
  # this is updated in persistence
  context.user_data['key'] = value
  # this is not updated in persistence
  context.application.user_data[other_user_id]['key'] = 'value'

Expected behaviour

user_data corresponding to other_user_id should be updated in persistence

Actual behaviour

only user_data corresponding to current_user_id is updated in persistence

Operating System

ubuntu 22.04

Version of Python, python-telegram-bot & dependencies

python-telegram-bot 20.0
Bot API 6.4
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]

Relevant log output

No response

Additional Context

I believe this error exists because of the following. Only update.effective_user.id is marked for persistence update.

def _mark_for_persistence_update(self, *, update: object = None, job: "Job" = None) -> None:
if isinstance(update, Update):
if update.effective_chat:
self._chat_ids_to_be_updated_in_persistence.add(update.effective_chat.id)
if update.effective_user:
self._user_ids_to_be_updated_in_persistence.add(update.effective_user.id)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions