{"record":{"id":"6823a0f4464da208","repo":"chenhg5/cc-connect","slug":"cloud-web-invalid-reply-context-type-t","errorCode":null,"errorMessage":"cloud_web: invalid reply context type %T","messagePattern":"cloud_web: invalid reply context type %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/cloud-web/cloudweb.go","lineNumber":696,"sourceCode":"\nfunc (p *Platform) sendWire(ctx context.Context, msg map[string]any) error {\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\treturn p.tp.Send(ctx, msg)\n}\n\nfunc parseReplyCtx(v any) (replyContext, error) {\n\tswitch rc := v.(type) {\n\tcase replyContext:\n\t\treturn rc, nil\n\tcase *replyContext:\n\t\tif rc == nil {\n\t\t\treturn replyContext{}, fmt.Errorf(\"cloud_web: nil reply context\")\n\t\t}\n\t\treturn *rc, nil\n\tdefault:\n\t\treturn replyContext{}, fmt.Errorf(\"cloud_web: invalid reply context type %T\", v)\n\t}\n}\n\nfunc firstNonEmpty(values ...string) string {\n\tfor _, v := range values {\n\t\tif strings.TrimSpace(v) != \"\" {\n\t\t\treturn v\n\t\t}\n\t}\n\treturn \"\"\n}\n","sourceCodeStart":678,"sourceCodeEnd":708,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/cloud-web/cloudweb.go#L678-L708","documentation":"parseReplyCtx rejects any value that is neither replyContext nor *replyContext. The %T verb prints the actual Go type of the offending value, so the message tells you exactly what was passed where a cloud-web reply context was expected. This guards against mixing reply-context types across platform adapters.","triggerScenarios":"Passing a reply context obtained from a different platform adapter (e.g. feishu or telegram reply context) into a cloud_web Platform's Reply/SendCard/SendWithButtons/UpdateMessage/DeletePreviewMessage, or passing a string/int handle.","commonSituations":"Generic engine code storing reply contexts in an any-typed map and routing to the wrong platform's send method; refactors that changed the context type without updating all call sites; tests reusing a fake context struct.","solutions":["Ensure the reply context passed to a cloud_web platform was produced by that same platform (its replyContext type)","Fix cross-platform wiring so each platform receives its own stored reply context","If wrapping contexts, unwrap to the underlying cloudweb replyContext before calling","Check the %T in the message to identify the wrong type and locate the code producing it"],"exampleFix":"// before\np.Reply(ctx, telegramCtx, \"hi\") // telegramCtx is *telegram.ReplyContext\n\n// after\ncwCtx, ok := ctxMap[sessionKey].(cloudweb.ReplyContext)\nif !ok {\n    return fmt.Errorf(\"wrong context type for cloud_web\")\n}\np.Reply(ctx, cwCtx, \"hi\")","handlingStrategy":"type-guard","validationCode":"if _, ok := v.(cloudweb.ReplyContext); !ok {\n    return fmt.Errorf(\"value is not a cloud_web reply context: %T\", v)\n}","typeGuard":"func isCloudWebReplyCtx(v any) bool { _, ok := v.(cloudweb.ReplyContext); return ok }","tryCatchPattern":"if err := p.Reply(ctx, v, msg); err != nil && strings.Contains(err.Error(), \"invalid reply context type\") {\n    return fmt.Errorf(\"wrong platform context routed to cloud_web: %w\", err)\n}","preventionTips":["Keep reply contexts keyed per platform so each send call receives its own type","Avoid passing raw handles (strings/ints) where the platform expects its context type","After platform refactors, grep send call sites for context type changes"],"tags":["cloud-web","type-mismatch","reply-context"],"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"}