{"record":{"id":"ed8953c0b3df0d82","repo":"chenhg5/cc-connect","slug":"weixin-no-stored-context-token-for-q-user-must","errorCode":null,"errorMessage":"weixin: no stored context_token for %q (user must message the bot first)","messagePattern":"weixin: no stored context_token for %q \\(user must message the bot first\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/weixin/weixin.go","lineNumber":914,"sourceCode":"\t\tn := maxRunes\n\t\tif len(runes) < n {\n\t\t\tn = len(runes)\n\t\t}\n\t\tout = append(out, string(runes[:n]))\n\t\trunes = runes[n:]\n\t}\n\treturn out\n}\n\n// ReconstructReplyCtx implements core.ReplyContextReconstructor for cron / proactive sends.\nfunc (p *Platform) ReconstructReplyCtx(sessionKey string) (any, error) {\n\tif !strings.HasPrefix(sessionKey, sessionKeyPrefix) {\n\t\treturn nil, fmt.Errorf(\"weixin: not a weixin session key\")\n\t}\n\tpeer := strings.TrimPrefix(sessionKey, sessionKeyPrefix)\n\ttok := p.getContextToken(peer)\n\tif tok == \"\" {\n\t\treturn nil, fmt.Errorf(\"weixin: no stored context_token for %q (user must message the bot first)\", peer)\n\t}\n\treturn &replyContext{peerUserID: peer, contextToken: tok}, nil\n}\n\n// FormattingInstructions implements core.FormattingInstructionProvider.\nfunc (p *Platform) FormattingInstructions() string {\n\treturn \"Replies are delivered as plain text to Weixin. Avoid markdown tables; use short paragraphs.\"\n}\n\nvar (\n\t_ core.Platform                      = (*Platform)(nil)\n\t_ core.ReplyContextReconstructor     = (*Platform)(nil)\n\t_ core.FormattingInstructionProvider = (*Platform)(nil)\n\t_ core.ImageSender                   = (*Platform)(nil)\n\t_ core.FileSender                    = (*Platform)(nil)\n\t_ core.TypingIndicator               = (*Platform)(nil)\n\t_ core.AsyncRecoverablePlatform      = (*Platform)(nil)\n)","sourceCodeStart":896,"sourceCodeEnd":932,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/weixin/weixin.go#L896-L932","documentation":"ReconstructReplyCtx resolved a valid weixin session key, but the platform has no stored context_token for that peer — Weixin requires the user to have messaged the bot first so a reply context exists, so a proactive/cron send to this peer is impossible.","triggerScenarios":"Thrown at platform/weixin/weixin.go:914 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait until the user sends the bot at least one message to establish a context_token, then re-enable the cron/proactive job","Skip and log rather than retry-looping: the token will not appear until user interaction"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}