{"record":{"id":"dcee022368cf7636","repo":"chenhg5/cc-connect","slug":"yuanbao-invalid-reply-context-type-t","errorCode":null,"errorMessage":"yuanbao: invalid reply context type %T","messagePattern":"yuanbao: invalid reply context type %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/yuanbao/platform.go","lineNumber":399,"sourceCode":"\t\tif content, ok := item[\"msg_content\"].(map[string]interface{}); ok {\n\t\t\telem.msgContent = content\n\t\t} else if mc, ok := item[\"MsgContent\"]; ok {\n\t\t\tswitch v := mc.(type) {\n\t\t\tcase map[string]interface{}:\n\t\t\t\telem.msgContent = v\n\t\t\tcase string:\n\t\t\t\t_ = json.Unmarshal([]byte(v), &elem.msgContent)\n\t\t\t}\n\t\t}\n\t\tresult = append(result, elem)\n\t}\n\treturn result\n}\n\nfunc (p *Platform) Reply(ctx context.Context, rctx any, content string) error {\n\trc, ok := rctx.(replyContext)\n\tif !ok {\n\t\treturn fmt.Errorf(\"yuanbao: invalid reply context type %T\", rctx)\n\t}\n\tif content == \"\" {\n\t\treturn nil\n\t}\n\tcontent = core.StripMarkdown(content)\n\tp.startReplyHeartbeat(rc.chatID)\n\tdefer p.stopReplyHeartbeat(rc.chatID, true)\n\tmsgBody := [][]byte{encodeTextBody(content)}\n\tvar frame []byte\n\tif rc.chatType == \"group\" {\n\t\tframe = encodeSendGroupMessage(rc.targetID, msgBody, p.getBotID(), \"\", \"\", \"\")\n\t} else {\n\t\tframe = encodeSendC2CMessage(rc.targetID, msgBody, p.getBotID(), \"\", 0, \"\", \"\")\n\t}\n\tws := p.getWS()\n\tif ws == nil {\n\t\treturn fmt.Errorf(\"yuanbao: not connected\")\n\t}","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/yuanbao/platform.go#L381-L417","documentation":"Reply expects the rctx parameter to be the platform's internal replyContext struct; if a caller passes any other type it returns this error including the actual type. Reply contexts must originate from this platform's message handling or ReconstructReplyCtx.","triggerScenarios":"Calling Reply with a reply context built by a different platform adapter, a nil value, or a hand-constructed map/struct; typically caused by mixing reply contexts across platforms in a bridge.","commonSituations":"Multi-platform setups where reply contexts are persisted globally and replayed against the wrong adapter; a session restore path returning the wrong context type.","solutions":["Ensure the rctx passed to Reply was produced by yuanbao's own message handling or ReconstructReplyCtx","Check that persisted reply contexts are keyed/stored per platform and restored for the matching adapter","Use ReconstructReplyCtx with a valid \"yuanbao:...\" session key to rebuild the context"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if rc, ok := rctx.(replyContext); !ok { return fmt.Errorf(\"not a yuanbao reply context\") }","typeGuard":"func isYuanbaoReplyCtx(rctx any) bool { _, ok := rctx.(replyContext); return ok }","tryCatchPattern":"if err := p.Reply(ctx, rctx, text); err != nil { if strings.Contains(err.Error(), \"invalid reply context type\") { slog.Error(\"wrong reply context for platform\", \"type\", fmt.Sprintf(\"%T\", rctx)) } }","preventionTips":["Persist reply contexts per-platform, never in a shared pool","Always obtain reply contexts from the same adapter that sends the reply","Rebuild contexts via ReconstructReplyCtx when restoring sessions"],"tags":["type-mismatch","reply-context","yuanbao"],"backgroundTag":"type-mismatch","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}