Skip to content

fix(telegram): clear_menus iterates global allowed_users causing USER_ID_INVALID on every group #839

Description

@adolfousier

Bug

In line ~1761, the / owner command registration loop chains global allowed_users into every group scope:

for uid in group.allowed_users.iter().chain(tg.allowed_users.iter()) {

This causes Telegram API USER_ID_INVALID errors on every group because the 4 global user IDs (8593093985, 686176803, 8365623776, 1611418118) are not members of most groups. The BotCommandScope::ChatMember call fails when the user isn't in the group.

Evidence

Same 4 errors on 9+ different groups in today's logs:

[ERROR] [agent] Failed to clear menu for user 8593093985 in group -1004332716514: USER_ID_INVALID
[ERROR] [agent] Failed to clear menu for user 686176803 in group -1004332716514: USER_ID_INVALID
[ERROR] [agent] Failed to clear menu for user 8365623776 in group -1004332716514: USER_ID_INVALID
[ERROR] [agent] Failed to clear menu for user 1611418118 in group -1004332716514: USER_ID_INVALID

Repeated for groups: -5483018934, -5509708814, -1003627148483, -1004406622817, -1004376662325, -5008492520, -1004446165687, -1004407925328.

Fix

Remove .chain(tg.allowed_users.iter()). Only clear menus for the group's own allowed_users. Global users who are in a group will already be in that group's allowed_users.

// Before
for uid in group.allowed_users.iter().chain(tg.allowed_users.iter()) {

// After
for uid in group.allowed_users.iter() {

Impact

  • 4 USER_ID_INVALID errors per group on every owner command registration
  • Noise in logs masking real errors
  • No functional breakage (menu clearing still works for actual group members)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions