{"record":{"id":"c49bd5c35a0922e7","repo":"chenhg5/cc-connect","slug":"wecom-invalid-session-key-q","errorCode":null,"errorMessage":"wecom: invalid session key %q","messagePattern":"wecom: invalid session key %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/wecom/wecom.go","lineNumber":713,"sourceCode":"\tif expires <= 0 {\n\t\tslog.Warn(\"wecom: missing/invalid expires_in in token response, defaulting to 7200s\", \"got\", result.ExpiresIn)\n\t\texpires = 7200\n\t}\n\tif expires > 60 {\n\t\texpires -= 60\n\t}\n\tp.tokenCache.token = result.AccessToken\n\tp.tokenCache.expiresAt = time.Now().Add(time.Duration(expires) * time.Second)\n\n\tslog.Debug(\"wecom: access_token refreshed\", \"expires_in\", result.ExpiresIn)\n\treturn result.AccessToken, nil\n}\n\nfunc (p *Platform) ReconstructReplyCtx(sessionKey string) (any, error) {\n\t// wecom:{userID}\n\tparts := strings.SplitN(sessionKey, \":\", 2)\n\tif len(parts) < 2 || parts[0] != \"wecom\" {\n\t\treturn nil, fmt.Errorf(\"wecom: invalid session key %q\", sessionKey)\n\t}\n\treturn replyContext{userID: parts[1]}, nil\n}\n\nfunc (p *Platform) Stop() error {\n\tif p.server != nil {\n\t\treturn p.server.Shutdown(context.Background())\n\t}\n\treturn nil\n}\n\n// --- Crypto helpers ---\n\n// verifySignature checks SHA1(sort(token, timestamp, nonce, encrypt)).\nfunc (p *Platform) verifySignature(expected, timestamp, nonce, encrypt string) bool {\n\tparts := []string{p.token, timestamp, nonce, encrypt}\n\tsort.Strings(parts)\n\th := sha1.New()","sourceCodeStart":695,"sourceCodeEnd":731,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/wecom/wecom.go#L695-L731","documentation":"Guard in the HTTP-platform ReconstructReplyCtx: the session key does not match the 'wecom:{userID}' format (missing prefix or fewer than two SplitN parts), so a usable reply context cannot be rebuilt for proactive sends. It indicates the engine handed this platform a session key minted elsewhere or a corrupted key.","triggerScenarios":"Thrown at platform/wecom/wecom.go:713 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure only session keys created by this platform's handler reach ReconstructReplyCtx","Have the engine dispatch reconstruction by platform prefix so mismatched keys never arrive","Log the offending key (included via %q) to trace the producing flow","Return the error so the caller skips the proactive send instead of misaddressing it"],"exampleFix":null,"handlingStrategy":"validation","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"}