chenhg5/cc-connect · error
cloud_web: nil reply context
Error message
cloud_web: nil reply context
What it means
parseReplyCtx normalizes the any-typed reply context passed to send APIs (Reply, SendCard, SendWithButtons, etc.). It accepts replyContext and *replyContext; a typed nil pointer (*replyContext)(nil) is explicitly rejected because dereferencing it would panic. This error signals the caller passed a nil pointer.
Source
Thrown at platform/cloud-web/cloudweb.go:692
return nil, fmt.Errorf("cloud_web: no stored reply context for session %q", sessionKey)
}
return replyContext{SessionKey: sessionKey, ReplyCtx: replyCtx}, nil
}
func (p *Platform) sendWire(ctx context.Context, msg map[string]any) error {
if ctx == nil {
ctx = context.Background()
}
return p.tp.Send(ctx, msg)
}
func parseReplyCtx(v any) (replyContext, error) {
switch rc := v.(type) {
case replyContext:
return rc, nil
case *replyContext:
if rc == nil {
return replyContext{}, fmt.Errorf("cloud_web: nil reply context")
}
return *rc, nil
default:
return replyContext{}, fmt.Errorf("cloud_web: invalid reply context type %T", v)
}
}
func firstNonEmpty(values ...string) string {
for _, v := range values {
if strings.TrimSpace(v) != "" {
return v
}
}
return ""
}
View on GitHub (pinned to 4000b2338a)
Solutions
- Check the reply context for nil before calling send APIs; skip the send or create a fresh session if nil
- Fix the upstream call whose error was ignored, leaving the handle nil
- Initialize the *replyContext before use, or pass a value (replyContext) instead of a pointer
Example fix
// before
var rc *cloudweb.ReplyContext
p.Reply(ctx, rc, "hi") // panics-avoidance error
// after
if rc == nil {
return fmt.Errorf("no reply context available")
}
p.Reply(ctx, rc, "hi") Defensive patterns
Strategy: type-guard
Validate before calling
if rc == nil {
return fmt.Errorf("cannot send: reply context is nil")
} Type guard
if rc, ok := v.(*cloudweb.ReplyContext); !ok || rc == nil { /* invalid/nil */ } Try / catch
if err := p.Reply(ctx, rc, msg); err != nil && strings.Contains(err.Error(), "nil reply context") {
return ErrNoReplyContext
} Prevention
- Always check errors from calls that produce reply contexts before using the handle
- Avoid typed-nil returns (return error, not (nil context, nil error))
- Initialize context fields at session creation, not lazily
When it happens
Trigger: Calling Reply/SendCard/SendWithButtons/UpdateMessage/SendPreviewStart/DeletePreviewMessage with a *replyContext variable that is nil — typically an uninitialized handle or the zero result of a failed lookup.
Common situations: Storing the result of a lookup that returned (nil, nil) or ignoring the error from a previous call and reusing a nil handle; struct fields of type *replyContext never assigned; a helper returning nil context on some code path.
Related errors
- cloud_web: invalid reply context type %T
- cloud_web: reconstruct_reply not supported by gateway
- cloud_web: no stored reply context for session %q
- qqbot: SendWithButtons: invalid reply context type %T
- webex: invalid reply context %T
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/9f02c446f322bf1b.
Report an issue: GitHub.