{"record":{"id":"2e5c369599bc3349","repo":"chenhg5/cc-connect","slug":"googlechat-invalid-reply-context-type-t-2e5c36","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/streaming.go","lineNumber":28,"sourceCode":"\t\"net/http\"\n\n\t\"github.com/chenhg5/cc-connect/core\"\n)\n\n// previewHandle points at the in-flight streaming-preview message so\n// UpdateMessage can patch it in place via spaces.messages.patch.\ntype previewHandle struct {\n\tname string // e.g. \"spaces/AAA/messages/MMM\"\n}\n\n// SendPreviewStart posts the initial streaming-preview message (threaded like a\n// normal reply) and returns a handle for subsequent edits. Implements\n// core.PreviewStarter; together with UpdateMessage it lights up the engine's\n// real-time streaming preview for Google Chat.\nfunc (p *Platform) SendPreviewStart(ctx context.Context, rctx any, content string) (any, error) {\n\trc, ok := rctx.(replyContext)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"googlechat: invalid reply context type %T\", rctx)\n\t}\n\tif rc.space == \"\" {\n\t\treturn nil, fmt.Errorf(\"googlechat: missing space in reply context\")\n\t}\n\turl, body, err := buildSendRequest(rc, content)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(body))\n\tif err != nil {\n\t\treturn nil, 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 nil, fmt.Errorf(\"googlechat: send preview: %w\", err)\n\t}\n\tdefer func() {","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/googlechat/streaming.go#L10-L46","documentation":"SendPreviewStart (core.PreviewStarter) type-asserts its reply-context argument to googlechat.replyContext. Any other value — including contexts from other platforms — fails and yields this error, which reports the actual dynamic type via %T.","triggerScenarios":"Streaming preview enabled for a googlechat agent but the engine hands SendPreviewStart a foreign/nil reply context; mixing platform adapters.","commonSituations":"Multi-platform deployments where the preview pipeline shares one context type; misconfigured platform routing sending a telegram/slack context to googlechat.","solutions":["Ensure streaming preview is only enabled for messages routed by the googlechat platform","Verify the platform wiring passes its own replyContext to SendPreviewStart","Add a capability check before enabling the preview feature for the platform"],"exampleFix":"// before\nhandle, err := gc.SendPreviewStart(ctx, otherCtx, content)\n// after\nif _, ok := otherCtx.(googlechat.ReplyContext); !ok {\n    return fmt.Errorf(\"preview not supported for this reply context\")\n}\nhandle, err := gc.SendPreviewStart(ctx, otherCtx, content)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func supportsPreview(rctx any) bool { _, ok := rctx.(replyContext); return ok }","tryCatchPattern":"handle, err := p.SendPreviewStart(ctx, rctx, content)\nif err != nil && strings.Contains(err.Error(), \"invalid reply context type\") {\n    return fallbackToPlainReply(ctx, rctx, content)\n}","preventionTips":["Enable streaming preview only on the googlechat platform instance","Route preview calls through the platform that produced the context","Check core.PreviewStarter capability before starting previews"],"tags":["googlechat","type-mismatch","streaming"],"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"}