chenhg5/cc-connect · error
webex: cannot reconstruct reply ctx from %q
Error message
webex: cannot reconstruct reply ctx from %q
What it means
ReconstructReplyCtx parses a persisted session key expected to be in the form "webex:{roomID}:{personID}" so cron jobs can rebuild a reply context. It throws this when the key does not have the "webex" prefix or lacks at least a roomID segment. This is a defensive check against corrupted or foreign session keys.
Source
Thrown at platform/webex/webex_reply.go:116
}
// SendFile implements core.FileSender.
func (p *Platform) SendFile(ctx context.Context, replyCtx any, file core.FileAttachment) error {
rc, err := asReplyContext(replyCtx)
if err != nil {
return err
}
return p.client.PostFile(ctx, rc.roomID, &downloadedFile{
Data: file.Data, MimeType: file.MimeType, FileName: file.FileName,
})
}
// ReconstructReplyCtx implements core.ReplyContextReconstructor for cron jobs.
// Session key format is "webex:{roomID}:{personID}".
func (p *Platform) ReconstructReplyCtx(sessionKey string) (any, error) {
parts := strings.SplitN(sessionKey, ":", 3)
if len(parts) < 2 || parts[0] != "webex" {
return nil, fmt.Errorf("webex: cannot reconstruct reply ctx from %q", sessionKey)
}
rc := replyContext{roomID: parts[1]}
if len(parts) == 3 {
rc.personID = parts[2]
}
return rc, nil
}
// FormattingInstructions implements core.FormattingInstructionProvider.
func (p *Platform) FormattingInstructions() string {
return "Webex supports standard Markdown (bold, italic, lists, code blocks, links). Use it freely."
}
// Compile-time interface conformance checks.
var (
_ core.Platform = (*Platform)(nil)
_ core.ImageSender = (*Platform)(nil)
_ core.FileSender = (*Platform)(nil)View on GitHub (pinned to 4000b2338a)
Solutions
- Check the session key stored for the cron job; it must start with "webex:" and contain the roomID.
- Correct the session key in your config/state to the "webex:{roomID}:{personID}" format.
- If migrating keys from another platform, recreate the session through the webex platform instead of reusing the key.
- Log the offending key value to trace which component wrote an invalid key.
Example fix
// before
ctx, err := p.ReconstructReplyCtx("feishu:ou_123") // wrong prefix
// after
ctx, err := p.ReconstructReplyCtx("webex:Y2lzY29zcGFyazovL3VzL1JPT00:personID") Defensive patterns
Strategy: validation
Validate before calling
func validWebexSessionKey(k string) bool {
parts := strings.SplitN(k, ":", 3)
return len(parts) >= 2 && parts[0] == "webex" && parts[1] != ""
} Type guard
func isWebexReplyCtx(v any) bool {
_, ok := v.(replyContext)
return ok
} Try / catch
rc, err := p.ReconstructReplyCtx(key)
if err != nil {
return fmt.Errorf("cron: bad session key %q: %w", key, err)
} Prevention
- Never hand-edit session keys; generate them via the platform
- Prefix-check keys before persisting them for cron jobs
- Validate keys after restoring from backups/migrations
When it happens
Trigger: Called with a sessionKey produced by another platform adapter, a manually edited/stale key, or a string missing the roomID field after the second colon-split part.
Common situations: Cron job config pointing at a session key copied from a different platform (e.g. "feishu:..."); storage migration losing the key prefix; an empty or truncated key restored from backup.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/38f016d01a79889d.
Report an issue: GitHub.