fix(telegram): use real forum topic id in unified create_thread - #1472
Closed
buddhism5080 wants to merge 1 commit into
Closed
fix(telegram): use real forum topic id in unified create_thread#1472buddhism5080 wants to merge 1 commit into
buddhism5080 wants to merge 1 commit into
Conversation
UnifiedGatewayAdapter::create_thread previously returned the triggering message_id as thread_id after fire-and-forget create_topic. Telegram forum replies then used a message id as message_thread_id, causing "message thread not found" while a real topic had already been created. Await create_topic GatewayResponse (oneshot via AppState.pending_commands), demux responses on the unified event bridge before process_gateway_event, and return the platform message_thread_id. Also stop mis-parsing GatewayResponse as GatewayEvent (null-as-string warnings). Add GH Actions workflow to build --features unified arm64/x64 artifacts for install without local compile.
|
Caution This PR has been waiting on the author for more than 2 days (labeled @buddhism5080 — You must add a new comment on this PR to remove the |
|
🔒 Auto-closing: this PR has had the If you'd like to continue working on this, please submit a new PR and link to this one if necessary. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Discord Discussion URL: https://discord.com/channels/1491129282771288286/1537276565849907241
Summary
EN: Fix unified-mode Telegram forum topics: after auto-creating a topic from the main chat, agent replies no longer go to a non-existent
message_thread_id(previously the trigger message id was misused as the topic id). Also demuxGatewayResponseon the unified event bridge socreate_topicresponses are not mis-parsed asGatewayEvent(which producedinvalid type: null, expected a string).中文: 修复 unified 模式下 Telegram 超群自动建 topic 后无发失败:此前
create_thread把触发消息的 message_id 当成 forum topic id 回传,导致Bad Request: message thread not found(topic 其实已建好)。同时在 unified 事件桥上先分发GatewayResponse,避免把createForumTopic的响应误当GatewayEvent解析报 null。Context
Production log (unified binary, Telegram forum supergroup):
creating forum topic→forum topic created thread_id=Some("8")unified bridge: event processing failed error=invalid gateway event JSON: invalid type: null, expected a stringgateway → telegram ... thread_id=Some("7")thentelegram send failed: Bad Request: message thread not foundRoot cause in
UnifiedGatewayAdapter::create_thread: fire-and-forgetcreate_topic, thenthread_id: Some(trigger_msg.message_id)— wrong id type for Telegram forums. Standalone WSGatewayAdapter::create_threadalready waited onGatewayResponse; unified did not.No existing open PR found for this fix (searched create_thread / forum topic / message thread not found).
Fix
AppState.pending_commands: oneshot map for in-process command responsesUnifiedGatewayAdapter::create_thread: register waiter, setrequest_id, await realthread_id(5s timeout, same as WS path)try_complete_pending+ main unified bridge: complete waiters beforeprocess_gateway_eventbuild-unified-binary.yml: build--features unifiedarm64/x64 artifacts (no local compile required)Review Contract
Goal
Unified Telegram deployments must reply into the forum topic that was just created from a main-chat message, using Telegram's real
message_thread_id.Non-goals
require_mentionconfig knobAccepted Residual Risks
create_topictimeout/failure, behavior still falls back to parent channel (same as WS adapter) — replies may land in General instead of a topic.GatewayResponsewith no waiter is dropped after demux (harmless; no longer spams invalid-event warnings).Acceptance Criteria
cargo clippy --workspace --features unified -- -D warningsandcargo test --workspace/ unified build succeed in CIcreate_threadusesresp.thread_idfromGatewayResponse, not trigger message idmessage thread not foundFollow-ups
event_txcompletingcreate_topicresponseGatewayAdapter::create_threadand unified path to avoid future driftTest Plan
GatewayAdapter::create_thread--features unifiedHow to Verify
src/unified_adapter.rscreate_thread+try_complete_pendingsrc/main.rsbridge demux orderRisk Assessment
Medium — touches unified event bridge and create_thread only; WS gateway path unchanged. Residual: timeout fallback still posts to parent chat.