{"record":{"id":"163ae2b4baf2278d","repo":"chenhg5/cc-connect","slug":"wecom-ws-invalid-reply-context-type-t","errorCode":null,"errorMessage":"wecom-ws: invalid reply context type %T","messagePattern":"wecom-ws: invalid reply context type %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/wecom/websocket.go","lineNumber":470,"sourceCode":"\t\t\tContent:  content, ExtraContent: quotedContent, ReplyCtx: rctx,\n\t\t})\n\t\treturn\n\t}\n\n\tslog.Info(\"wecom-ws: media message\", \"msg_type\", body.MsgType, \"user\", body.From.UserID,\n\t\t\"images\", len(current.images)+len(quoted.images), \"files\", len(current.files)+len(quoted.files), \"text_parts\", len(current.content))\n\tgo p.deliverWSMediaInbound(&body, sessionKey, chatName, rctx, current, quoted, false)\n}\n\n// Reply sends a response message via aibot_respond_msg using the stream format.\n// Uses the req_id from the original callback.\n// The stream content field is a full-replacement (not incremental append), so we\n// send the complete content in one frame with finish=true.\n// Markdown is natively supported by the stream reply format.\nfunc (p *WSPlatform) Reply(ctx context.Context, rctx any, content string) error {\n\trc, ok := rctx.(wsReplyContext)\n\tif !ok {\n\t\treturn fmt.Errorf(\"wecom-ws: invalid reply context type %T\", rctx)\n\t}\n\tif content == \"\" {\n\t\treturn nil\n\t}\n\n\tstreamID := p.generateReqID(\"stream\")\n\tframe := map[string]any{\n\t\t\"cmd\":     \"aibot_respond_msg\",\n\t\t\"headers\": map[string]string{\"req_id\": rc.reqID},\n\t\t\"body\": map[string]any{\n\t\t\t\"msgtype\": \"stream\",\n\t\t\t\"stream\": map[string]any{\n\t\t\t\t\"id\":      streamID,\n\t\t\t\t\"finish\":  true,\n\t\t\t\t\"content\": content,\n\t\t\t},\n\t\t},\n\t}","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/wecom/websocket.go#L452-L488","documentation":"Type-assertion guard inside wecom-ws Reply: the reply context value passed in by the engine is not a platform/wecom wsReplyContext (the struct carrying req_id/chatID/userID obtained from the original aibot callback). Any other type — including a context reconstructed by a different platform or a nil/anonymous value — cannot be used to address the aibot_respond_msg frame, so the send is refused before any I/O.","triggerScenarios":"Thrown at platform/wecom/websocket.go:470 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure only contexts produced by this platform's message callback (or ReconstructReplyCtx) are routed back into Reply","If the context came from another platform, fix the engine's session/platform binding so replies are dispatched to the platform that received the original message","For cron/proactive flows that lack a req_id, call Send (aibot_send_msg) instead of Reply","Add a test asserting the engine never forwards a foreign context type"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}