{"record":{"id":"09ba135141f5c8e0","repo":"chenhg5/cc-connect","slug":"wecom-invalid-reply-context-type-t","errorCode":null,"errorMessage":"wecom: invalid reply context type %T","messagePattern":"wecom: invalid reply context type %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/wecom/wecom.go","lineNumber":455,"sourceCode":"\t\t\t\t\tData:     fileData,\n\t\t\t\t\tFileName: baseName,\n\t\t\t\t}},\n\t\t\t\tReplyCtx: rctx,\n\t\t\t})\n\t\t}()\n\n\tdefault:\n\t\tslog.Warn(\"wecom: unsupported inbound message type (no handler)\",\n\t\t\t\"msg_type\", msg.MsgType,\n\t\t\t\"msg_id\", msg.MsgId,\n\t\t\t\"from_user\", msg.FromUserName)\n\t}\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(\"wecom: invalid reply context type %T\", rctx)\n\t}\n\tif content == \"\" {\n\t\treturn nil\n\t}\n\n\taccessToken, err := p.getAccessToken()\n\tif err != nil {\n\t\tslog.Error(\"wecom: get access_token failed\", \"error\", err)\n\t\treturn fmt.Errorf(\"wecom: get access_token: %w\", err)\n\t}\n\n\tif !p.enableMarkdown {\n\t\tcontent = core.StripMarkdown(content)\n\t}\n\n\tchunks := splitByBytes(content, 2000)\n\tfor i, chunk := range chunks {\n\t\tvar sendErr error","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/wecom/wecom.go#L437-L473","documentation":"Reply() expects the reply context argument to be the platform's internal replyContext struct, which carries the userID needed to address the message. Passing anything else (nil, a string, another platform's context type) makes the type assertion fail and returns this error naming the actual dynamic type.","triggerScenarios":"Calling p.Reply(ctx, rctx, content) with a rctx that was not produced by this wecom platform's message handling — e.g. nil, a string chat ID, or a reply context from a different platform adapter.","commonSituations":"Bridging messages across platforms and forwarding another platform's reply context; custom automation code inventing a context instead of using the one delivered with the inbound message; a refactor that changed replyContext's type/shape while old callers still pass the old value.","solutions":["Pass the exact replyContext value the engine gave you with the inbound message; never construct one manually","Check you are not mixing reply contexts between platform adapters (each is a distinct Go type)","If you only have a user ID and need to send proactively, use the platform's Send path rather than Reply","Update stale callers after refactors of the replyContext type"],"exampleFix":"// before\nerr := p.Reply(ctx, \"user123\", \"hi\") // wrong type\n// after\nerr := p.Reply(ctx, msg.ReplyContext(), \"hi\") // the replyContext from the inbound message","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func asWecomReplyContext(rctx any) (wecomReplyContext, bool) {\n\trc, ok := rctx.(replyContext)\n\treturn rc, ok\n}","tryCatchPattern":"rc, ok := rctx.(replyContext)\nif !ok {\n\treturn fmt.Errorf(\"cannot reply: expected wecom replyContext, got %T\", rctx)\n}","preventionTips":["Always thread the reply context from the engine's inbound message through to Reply()","Never construct reply contexts by hand or share them across platform adapters","Add a compile-time note/interface where your middleware carries reply contexts"],"tags":["wecom","type-mismatch","api-misuse"],"backgroundTag":"type-mismatch","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"}