{"record":{"id":"82943f995a05503b","repo":"chenhg5/cc-connect","slug":"googlechat-invalid-reply-context-type-t","errorCode":null,"errorMessage":"googlechat: invalid reply context type %T","messagePattern":"googlechat: invalid reply context type %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/googlechat/googlechat.go","lineNumber":416,"sourceCode":"\n// doRequest executes req using botClient and returns the response on success.\n// On non-2xx it reads the error body, closes it, and returns an error.\n// The caller is responsible for draining and closing resp.Body on success.\nfunc (p *Platform) doRequest(req *http.Request) (*http.Response, error) {\n\tresp, err := p.botClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif resp.StatusCode >= 300 {\n\t\treturn nil, httpErrorBody(resp, fmt.Sprintf(\"googlechat: %s %s\", req.Method, req.URL.Path))\n\t}\n\treturn resp, nil\n}\n\nfunc (p *Platform) post(ctx context.Context, rctx any, content string) error {\n\trc, ok := rctx.(replyContext)\n\tif !ok {\n\t\treturn fmt.Errorf(\"googlechat: invalid reply context type %T\", rctx)\n\t}\n\tif rc.space == \"\" {\n\t\treturn fmt.Errorf(\"googlechat: missing space in reply context\")\n\t}\n\turl, body, err := buildSendRequest(rc, content)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(body))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"googlechat: build request: %w\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\tresp, err := p.doRequest(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif _, err := io.Copy(io.Discard, resp.Body); err != nil {","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/googlechat/googlechat.go#L398-L434","documentation":"post expects the reply-context argument to be the platform's concrete replyContext struct (as produced by ReceiveMessage handling or ReconstructReplyCtx). This error is thrown when some other type is passed, meaning an engine or caller handed googlechat a reply context it did not create. It is an internal type-contract violation guard.","triggerScenarios":"Passing a reply context created by another platform (e.g. telegram's reply context), a raw string space name, or nil into post via Reply/Send or a custom integration.","commonSituations":"Cross-platform session switching where a session key was reconstructed by the wrong platform; custom code in cron or send-to-session features injecting hand-built context values; mixing core reply-context types across platform adapters.","solutions":["Ensure the reply context came from googlechat's own ReconstructReplyCtx (via the googlechat-prefixed session key), not another platform's","Check session persistence so platform identity is preserved across restarts and /switch operations","If writing custom code, use replyContext{space: \"spaces/...\", thread: \"spaces/.../threads/...\"} from the googlechat package"],"exampleFix":"// before\nerr := p.post(ctx, \"spaces/AAAA\", \"hello\") // string, wrong type\n\n// after\nrc, err := p.ReconstructReplyCtx(\"googlechat:spaces/AAAA\")\nif err != nil { return err }\nerr = p.post(ctx, rc, \"hello\")","handlingStrategy":"type-guard","validationCode":"if _, ok := rctx.(replyContext); !ok { return fmt.Errorf(\"googlechat: expected replyContext, got %T\", rctx) }","typeGuard":"func asGoogleChatReplyCtx(v any) (replyContext, bool) { rc, ok := v.(replyContext); return rc, ok }","tryCatchPattern":"if err := p.post(ctx, rctx, content); err != nil {\n    if strings.Contains(err.Error(), \"invalid reply context type\") {\n        // context came from another platform; re-derive via ReconstructReplyCtx\n        rc, rerr := p.ReconstructReplyCtx(sessionKey)\n        ...\n    }\n}","preventionTips":["Never mix reply contexts between platform adapters; keep them platform-scoped","Persist the platform name alongside the session key and route sends to the matching platform","When writing custom send paths, always derive the context from that platform's ReconstructReplyCtx"],"tags":["googlechat","type-error","internal"],"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"}