Skip to content

fix(telegram-e2e): harden mtproto reply matching [AI-assisted]#107

Merged
artemgetmann merged 1 commit into
mainfrom
codex/browser-upstream-port-20260324
Mar 24, 2026
Merged

fix(telegram-e2e): harden mtproto reply matching [AI-assisted]#107
artemgetmann merged 1 commit into
mainfrom
codex/browser-upstream-port-20260324

Conversation

@artemgetmann
Copy link
Copy Markdown
Owner

Summary

  • Problem: the shared Telegram MTProto waiter could miss real tester-bot replies in DM/private-topic flows because it only looked at classic reply metadata and gave weak timeout diagnostics.
  • Why it matters: shared Telegram E2E tooling can report false negatives even when the tester bot actually replied, which wastes time during runtime/browser verification.
  • What changed: scripts/telegram-e2e/userbot_wait.py now understands direct_messages_topic.topic_id, emits ignored-message diagnostics on timeout, and reports sender mismatches clearly.
  • What did NOT change (scope boundary): this PR does not reintroduce consumer-only smoke scripts on main; it only hardens the shared MTProto waiter.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

  • Shared Telegram MTProto waiting logic is more reliable for DM/private-topic tester-bot replies.
  • Timeout failures now show the ignored recent messages and why they were skipped.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: local checkout tooling
  • Model/provider: N/A
  • Integration/channel (if any): Telegram MTProto helper
  • Relevant config (redacted): none

Steps

  1. Run python3 -m py_compile scripts/telegram-e2e/userbot_wait.py.
  2. Compare the waiter logic against the proven consumer fix.
  3. Confirm the branch contains only the shared waiter hardening, not the consumer-only smoke wrapper.

Expected

  • The waiter understands DM/private-topic metadata and surfaces actionable timeout diagnostics.

Actual

  • The script compiles cleanly and the shared matching logic now mirrors the proven consumer waiter fix.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios:
    • python3 -m py_compile scripts/telegram-e2e/userbot_wait.py
    • inspected the main branch Telegram E2E layout and intentionally kept the consumer-only smoke wrapper out of this port
    • aligned the waiter behavior with the already proven consumer fix
  • Edge cases checked:
    • direct_messages_topic.topic_id now resolves thread anchors
    • ignored-message diagnostics include sender/thread/text mismatch reasons
  • What you did not verify:
    • a full live Telegram roundtrip from the main branch checkout
    • consumer-only smoke scripts, because they are not present on main

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert commit 697e41ba2e
  • Files/config to restore: scripts/telegram-e2e/userbot_wait.py
  • Known bad symptoms reviewers should watch for: MTProto waiter timing out on real bot replies or reporting unhelpful timeout payloads

Risks and Mitigations

  • Risk: Telegram may emit thread metadata differently across chat types.
    • Mitigation: the waiter now checks both classic reply metadata and direct_messages_topic.topic_id, and exposes ignored-message diagnostics when matching still fails.

AI Assistance

  • AI-assisted
  • Testing: lightly tested on main, fully proven on the equivalent consumer lane
  • codex review was attempted, but local skill/MCP startup errors prevented a clean run in this environment

@artemgetmann artemgetmann merged commit 4baeddf into main Mar 24, 2026
3 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant