iflytek/astron-agent · error · BusinessException

LONG_CONTENT_FILE_NUM_OUT_LIMIT

LONG_CONTENT_FILE_NUM_OUT_LIMIT

Error message

LONG_CONTENT_FILE_NUM_OUT_LIMIT

What it means

checkFile enforces a per-user daily upload quota using a Redisson AtomicLong keyed by limitEnum.getRedisPrefix() + uid. If incrementing the counter pushes it above limitEnum.getDailyUploadNum(), the counter is rolled back by 1 and LONG_CONTENT_FILE_NUM_OUT_LIMIT is thrown.

Solutions

  1. Wait until the daily window resets or ask an admin to clear the Redis key <redisPrefix><uid> if the quota is wrong.
  2. Avoid client-side retry loops that re-call saveFile after a failure without confirming the upload did not land.
  3. If the quota is too low for the use case, raise dailyUploadNum on the relevant ChatFileLimitEnum constant.
  4. Verify distinct users are not sharing one uid/token, which would conflate their counters.

Example fix

// before
for (File f : files) { saveFile(...); } // partial failure leaves counter incremented, retries exceed quota
// after
long remaining = dailyUploadNum - counter.get();
if (files.length > remaining) {
    throw new IllegalStateException("Only " + remaining + " uploads left today");
}
for (File f : files) { saveFile(...); }
Defensive patterns

Strategy: try-catch

Validate before calling

String redisKey = ChatFileLimitEnum.DOCUMENT.getRedisPrefix() + uid;
long used = redissonClient.getAtomicLong(redisKey).get();
if (used >= ChatFileLimitEnum.DOCUMENT.getDailyUploadNum()) {
    throw new IllegalStateException("Daily upload quota exhausted");
}

Try / catch

try {
    chatEnhanceService.saveFile(uid, fileName, fileUrl, fileSize, businessType);
} catch (BusinessException e) {
    if (ResponseEnum.LONG_CONTENT_FILE_NUM_OUT_LIMIT.equals(e.getResponseEnum())) {
        // show remaining-quota message; do not auto-retry
    }
}

Prevention

When it happens

Trigger: A user making more than dailyUploadNum uploads of that business type within one day (the Redis counter is not TTL-reset in this snippet, so it is keyed by prefix+uid); automated clients or retry loops re-invoking saveFile repeatedly and exhausting the quota.

Common situations: Users hitting the daily cap after bulk-uploading chat documents; frontend retry logic re-submitting failed uploads and double-counting; load tests tripping the quota; a shared uid (e.g. service account) used by many people exhausting the shared counter.

Related errors


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

Appendix: source

Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/chat/impl/ChatEnhanceServiceImpl.java:231

     * @param limitEnum File limit enum, including maximum file size and daily upload count limit
     * @throws BusinessException Business exception thrown when file name or URL is empty, business type
     *         is wrong, file size exceeds limit or daily upload count exceeds limit
     */
    private void checkFile(String uid, String fileName, String fileUrl, Long fileSize, ChatFileLimitEnum limitEnum) {
        if (StringUtils.isBlank(fileName) || StringUtils.isBlank(fileUrl)) {
            throw new BusinessException(ResponseEnum.LONG_CONTENT_MISS_FILE_INFO);
        }
        if (limitEnum == null) {
            throw new BusinessException(ResponseEnum.LONG_CONTENT_WRONG_BUSINESS_TYPE);
        }
        // Current document size validation
        if (fileSize > limitEnum.getMaxSize()) {
            throw new BusinessException(ResponseEnum.LONG_CONTENT_FILE_SIZE_OUT_LIMIT);
        }
        // Daily maximum upload count limit
        if (redissonClient.getAtomicLong(limitEnum.getRedisPrefix() + uid).addAndGet(1L) > limitEnum.getDailyUploadNum()) {
            redissonClient.getAtomicLong(limitEnum.getRedisPrefix() + uid).addAndGet(-1L);
            throw new BusinessException(ResponseEnum.LONG_CONTENT_FILE_NUM_OUT_LIMIT);
        }
    }

    /**
     * Handle document upload functionality
     *
     * @param chatFileUserId Chat file user ID
     * @param uid User ID
     * @param chatId Chat ID
     * @param fileUrl File URL
     * @param fileName File name
     * @param fileSize File size
     * @param limitEnum File limit enum
     * @param fileBusinessKey File business key
     * @param documentType Document type
     * @param paramName Parameter name
     * @return Returns a Map containing processing results
     */

View on GitHub (pinned to 5e758547a8)