chenhg5/cc-connect · error
googlechat: invalid reply context type %T
Error message
googlechat: invalid reply context type %T
What it means
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.
Source
Thrown at platform/googlechat/streaming.go:28
"net/http"
"github.com/chenhg5/cc-connect/core"
)
// previewHandle points at the in-flight streaming-preview message so
// UpdateMessage can patch it in place via spaces.messages.patch.
type previewHandle struct {
name string // e.g. "spaces/AAA/messages/MMM"
}
// SendPreviewStart posts the initial streaming-preview message (threaded like a
// normal reply) and returns a handle for subsequent edits. Implements
// core.PreviewStarter; together with UpdateMessage it lights up the engine's
// real-time streaming preview for Google Chat.
func (p *Platform) SendPreviewStart(ctx context.Context, rctx any, content string) (any, error) {
rc, ok := rctx.(replyContext)
if !ok {
return nil, fmt.Errorf("googlechat: invalid reply context type %T", rctx)
}
if rc.space == "" {
return nil, fmt.Errorf("googlechat: missing space in reply context")
}
url, body, err := buildSendRequest(rc, content)
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(body))
if err != nil {
return nil, fmt.Errorf("googlechat: build request: %w", err)
}
req.Header.Set("Content-Type", "application/json")
resp, err := p.doRequest(req)
if err != nil {
return nil, fmt.Errorf("googlechat: send preview: %w", err)
}
defer func() {View on GitHub (pinned to 4000b2338a)
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
Example fix
// before
handle, err := gc.SendPreviewStart(ctx, otherCtx, content)
// after
if _, ok := otherCtx.(googlechat.ReplyContext); !ok {
return fmt.Errorf("preview not supported for this reply context")
}
handle, err := gc.SendPreviewStart(ctx, otherCtx, content) Defensive patterns
Strategy: type-guard
Type guard
func supportsPreview(rctx any) bool { _, ok := rctx.(replyContext); return ok } Try / catch
handle, err := p.SendPreviewStart(ctx, rctx, content)
if err != nil && strings.Contains(err.Error(), "invalid reply context type") {
return fallbackToPlainReply(ctx, rctx, content)
} Prevention
- 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
When it happens
Trigger: Streaming preview enabled for a googlechat agent but the engine hands SendPreviewStart a foreign/nil reply context; mixing platform adapters.
Common situations: Multi-platform deployments where the preview pipeline shares one context type; misconfigured platform routing sending a telegram/slack context to googlechat.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- googlechat: SendImage: invalid reply context type %T
- googlechat: SendFile: invalid reply context type %T
- googlechat: missing space in reply context
- googlechat: build request: %w
- googlechat: send preview: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/2e5c369599bc3349.
Report an issue: GitHub.