chenhg5/cc-connect · error
webex: invalid reply context %T
Error message
webex: invalid reply context %T
What it means
asReplyContext recovers the platform-specific replyContext from the engine's any-typed reply context value. If the value was not produced by this Webex platform (wrong concrete type), it returns this error naming the actual Go type received. It is an internal invariant violation across the platform boundary.
Source
Thrown at platform/webex/webex_reply.go:19
package webex
import (
"context"
"fmt"
"strings"
"unicode/utf8"
"github.com/chenhg5/cc-connect/core"
)
// webexMaxBytes is Webex's per-message body cap.
const webexMaxBytes = 7439
// asReplyContext recovers a replyContext from the engine's any-typed value.
func asReplyContext(replyCtx any) (replyContext, error) {
rc, ok := replyCtx.(replyContext)
if !ok {
return replyContext{}, fmt.Errorf("webex: invalid reply context %T", replyCtx)
}
return rc, nil
}
// Reply posts a threaded response to the originating message.
func (p *Platform) Reply(ctx context.Context, replyCtx any, content string) error {
rc, err := asReplyContext(replyCtx)
if err != nil {
return err
}
return p.post(ctx, rc.roomID, rc.messageID, content)
}
// Send posts a non-threaded (proactive) message to the room.
func (p *Platform) Send(ctx context.Context, replyCtx any, content string) error {
rc, err := asReplyContext(replyCtx)
if err != nil {
return errView on GitHub (pinned to 4000b2338a)
Solutions
- Always pass the replyCtx value received from the engine's message event back verbatim — never reconstruct it
- Ensure messages from other platforms are not routed to the Webex platform's Reply/Send
- Check engine routing logic for mixing reply contexts across platforms
- In tests, use the actual replyContext returned by the Webex platform rather than a hand-made value
Example fix
// before
p.Reply(ctx, someOtherPlatformCtx, "hi")
// after
if msg.Platform == "webex" {
p.Reply(ctx, msg.ReplyContext, "hi")
} Defensive patterns
Strategy: type-guard
Validate before calling
if _, ok := replyCtx.(webex.ReplyContext); !ok {
return errors.New("reply context does not belong to webex platform")
} Type guard
func isValidWebexReplyContext(v any) bool {
_, ok := v.(webex.ReplyContext)
return ok
} Try / catch
if err := p.Reply(ctx, replyCtx, text); err != nil {
if strings.Contains(err.Error(), "invalid reply context") {
return fmt.Errorf("reply ctx not from webex; check routing: %w", err)
}
return err
} Prevention
- Always return the replyCtx from the message event untouched — never rebuild or copy fields
- Never route one platform's reply context to a different platform's Reply/Send
- Use type-guard checks at routing boundaries before dispatching to platform adapters
- Add engine tests covering cross-platform routing to catch context mixing early
When it happens
Trigger: Calling Reply/Send/SendImage/SendFile with a replyCtx value captured from a different platform's message, a nil value, or an altered/reconstructed value that is not of type replyContext.
Common situations: Routing engine bug forwarding another platform's reply context to the Webex platform; storing a reply context, restarting with a different platform type, then replying; tests passing a raw string/struct instead of the value obtained from ReceiveMessage.
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
- cloud_web: nil reply context
- cloud_web: invalid reply context type %T
- qqbot: SendWithButtons: invalid reply context type %T
- weixin: invalid reply context
- yuanbao: invalid reply context type %T
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/6245c840d1e64356.
Report an issue: GitHub.