{"record":{"id":"3f6f8e1850ff3946","repo":"iflytek/astron-agent","slug":"pre-binding-user-id-not-found-appid-botid","errorCode":null,"errorMessage":"Pre-binding user ID not found: appid={}, botId={}","messagePattern":"Pre-binding user ID not found: appid=(.+?), botId=(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/wechat/impl/WechatThirdpartyServiceImpl.java","lineNumber":273,"sourceCode":"     */\n    private String getUidFromPreBindInfo(String appid, Integer botId) {\n        String preBindKey = PRE_BIND_KEY + appid;\n        RBucket<String> bucket = redissonClient.getBucket(preBindKey);\n\n        if (bucket.isExists()) {\n            String preBindInfo = bucket.get();\n            try {\n                // Parse botId:uid format\n                String[] parts = preBindInfo.split(\":\");\n                if (parts.length >= 2) {\n                    return parts[1];\n                }\n            } catch (Exception e) {\n                log.warn(\"Failed to parse user ID from pre-binding information: appid={}, preBindInfo={}\", appid, preBindInfo, e);\n            }\n        }\n\n        log.warn(\"Pre-binding user ID not found: appid={}, botId={}\", appid, botId);\n        return null;\n    }\n\n    /**\n     * Clean up pre-binding cache\n     */\n    private void cleanupPreBindCache(String appid, Integer botId) {\n        // Clean up pre-binding status\n        String preBindKey = PRE_BIND_KEY + appid;\n        redissonClient.getBucket(preBindKey).delete();\n\n        // Clean up pre-authorization code\n        String preAuthCodeKey = PRE_AUTH_CODE_KEY + botId;\n        redissonClient.getBucket(preAuthCodeKey).delete();\n\n        log.debug(\"Cleaned up pre-binding cache: appid={}, botId={}\", appid, botId);\n    }\n","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/wechat/impl/WechatThirdpartyServiceImpl.java#L255-L291","documentation":"WARN from getUidFromPreBindInfo: after checking the cache, no pre-binding record yielded a uid for the appid/botId pair, so the method returns null. Callers (e.g. the WeChat bind callback) receive null uid and must handle the missing association.","triggerScenarios":"WeChat bind/scan callback arrives after the pre-bind cache entry expired or was never created; botId/appid mismatch between the QR code generation step and the callback.","commonSituations":"Users scanning a QR code long after generation (TTL elapsed); redeployments flushing the pre-bind cache; generating bind QR with one appid while callback uses another (env misconfiguration).","solutions":["Re-generate the bind QR / pre-bind entry and have the user retry the scan within the TTL window.","Increase pre-bind cache TTL or store the mapping durably (DB) instead of only in cache.","Ensure the caller treats null uid as 'binding session expired' and returns a clear error to the client."],"exampleFix":"// before\nString uid = wechatThirdpartyService.getUidFromPreBindInfo(appid, botId);\nprocessBind(uid, ...);\n// after\nString uid = wechatThirdpartyService.getUidFromPreBindInfo(appid, botId);\nif (uid == null) { throw new BusinessException(ResponseEnum.PRE_BIND_EXPIRED); }","handlingStrategy":"retry","validationCode":"String uid = getUidFromPreBindInfo(appid, botId);\nif (uid == null) { /* prompt user to regenerate QR and rescan */ }","typeGuard":"static boolean preBindPresent(String uid) { return uid != null && !uid.isBlank(); }","tryCatchPattern":"try {\n    processBind(uid, ...);\n} catch (PreBindExpiredException e) {\n    return ApiResult.error(ResponseEnum.PRE_BIND_EXPIRED); // client regenerates QR\n}","preventionTips":["Set a pre-bind TTL longer than expected QR scan time and show expiry on the client.","Persist pre-bind mappings durably for critical flows.","Use consistent appid/botId between QR generation and callback config."],"tags":["wechat","cache-expiry","pre-bind","qr-login"],"backgroundTag":"record-not-found","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}