iflytek/astron-agent · warning

Pre-binding user ID not found: appid=

Error message

Pre-binding user ID not found: appid={}, botId={}

What it means

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.

Solutions

  1. Re-generate the bind QR / pre-bind entry and have the user retry the scan within the TTL window.
  2. Increase pre-bind cache TTL or store the mapping durably (DB) instead of only in cache.
  3. Ensure the caller treats null uid as 'binding session expired' and returns a clear error to the client.

Example fix

// before
String uid = wechatThirdpartyService.getUidFromPreBindInfo(appid, botId);
processBind(uid, ...);
// after
String uid = wechatThirdpartyService.getUidFromPreBindInfo(appid, botId);
if (uid == null) { throw new BusinessException(ResponseEnum.PRE_BIND_EXPIRED); }
Defensive patterns

Strategy: retry

Validate before calling

String uid = getUidFromPreBindInfo(appid, botId);
if (uid == null) { /* prompt user to regenerate QR and rescan */ }

Type guard

static boolean preBindPresent(String uid) { return uid != null && !uid.isBlank(); }

Try / catch

try {
    processBind(uid, ...);
} catch (PreBindExpiredException e) {
    return ApiResult.error(ResponseEnum.PRE_BIND_EXPIRED); // client regenerates QR
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/3f6f8e1850ff3946. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/wechat/impl/WechatThirdpartyServiceImpl.java:273

     */
    private String getUidFromPreBindInfo(String appid, Integer botId) {
        String preBindKey = PRE_BIND_KEY + appid;
        RBucket<String> bucket = redissonClient.getBucket(preBindKey);

        if (bucket.isExists()) {
            String preBindInfo = bucket.get();
            try {
                // Parse botId:uid format
                String[] parts = preBindInfo.split(":");
                if (parts.length >= 2) {
                    return parts[1];
                }
            } catch (Exception e) {
                log.warn("Failed to parse user ID from pre-binding information: appid={}, preBindInfo={}", appid, preBindInfo, e);
            }
        }

        log.warn("Pre-binding user ID not found: appid={}, botId={}", appid, botId);
        return null;
    }

    /**
     * Clean up pre-binding cache
     */
    private void cleanupPreBindCache(String appid, Integer botId) {
        // Clean up pre-binding status
        String preBindKey = PRE_BIND_KEY + appid;
        redissonClient.getBucket(preBindKey).delete();

        // Clean up pre-authorization code
        String preAuthCodeKey = PRE_AUTH_CODE_KEY + botId;
        redissonClient.getBucket(preAuthCodeKey).delete();

        log.debug("Cleaned up pre-binding cache: appid={}, botId={}", appid, botId);
    }

View on GitHub (pinned to 5e758547a8)