Skip to content

Commit

Permalink
Fix KeyError when ID is in cache but queried without mark
Browse files Browse the repository at this point in the history
Closes #4084.
  • Loading branch information
Lonami committed May 4, 2023
1 parent c4a41ad commit 980f8b3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions telethon/client/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,9 @@ async def get_entity(

# Merge users, chats and channels into a single dictionary
id_entity = {
utils.get_peer_id(x): x
# `get_input_entity` might've guessed the type from a non-marked ID,
# so the only way to match that with the input is by not using marks here.
utils.get_peer_id(x, add_mark=False): x
for x in itertools.chain(users, chats, channels)
}

Expand All @@ -329,7 +331,7 @@ async def get_entity(
if isinstance(x, str):
result.append(await self._get_entity_from_string(x))
elif not isinstance(x, types.InputPeerSelf):
result.append(id_entity[utils.get_peer_id(x)])
result.append(id_entity[utils.get_peer_id(x, add_mark=False)])
else:
result.append(next(
u for u in id_entity.values()
Expand Down

0 comments on commit 980f8b3

Please sign in to comment.