{"record":{"id":"de38127d22b3398e","repo":"iflytek/astron-agent","slug":"long-content-file-num-out-limit","errorCode":"LONG_CONTENT_FILE_NUM_OUT_LIMIT","errorMessage":"LONG_CONTENT_FILE_NUM_OUT_LIMIT","messagePattern":"LONG_CONTENT_FILE_NUM_OUT_LIMIT","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/chat/impl/ChatEnhanceServiceImpl.java","lineNumber":231,"sourceCode":"     * @param limitEnum File limit enum, including maximum file size and daily upload count limit\n     * @throws BusinessException Business exception thrown when file name or URL is empty, business type\n     *         is wrong, file size exceeds limit or daily upload count exceeds limit\n     */\n    private void checkFile(String uid, String fileName, String fileUrl, Long fileSize, ChatFileLimitEnum limitEnum) {\n        if (StringUtils.isBlank(fileName) || StringUtils.isBlank(fileUrl)) {\n            throw new BusinessException(ResponseEnum.LONG_CONTENT_MISS_FILE_INFO);\n        }\n        if (limitEnum == null) {\n            throw new BusinessException(ResponseEnum.LONG_CONTENT_WRONG_BUSINESS_TYPE);\n        }\n        // Current document size validation\n        if (fileSize > limitEnum.getMaxSize()) {\n            throw new BusinessException(ResponseEnum.LONG_CONTENT_FILE_SIZE_OUT_LIMIT);\n        }\n        // Daily maximum upload count limit\n        if (redissonClient.getAtomicLong(limitEnum.getRedisPrefix() + uid).addAndGet(1L) > limitEnum.getDailyUploadNum()) {\n            redissonClient.getAtomicLong(limitEnum.getRedisPrefix() + uid).addAndGet(-1L);\n            throw new BusinessException(ResponseEnum.LONG_CONTENT_FILE_NUM_OUT_LIMIT);\n        }\n    }\n\n    /**\n     * Handle document upload functionality\n     *\n     * @param chatFileUserId Chat file user ID\n     * @param uid User ID\n     * @param chatId Chat ID\n     * @param fileUrl File URL\n     * @param fileName File name\n     * @param fileSize File size\n     * @param limitEnum File limit enum\n     * @param fileBusinessKey File business key\n     * @param documentType Document type\n     * @param paramName Parameter name\n     * @return Returns a Map containing processing results\n     */","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/chat/impl/ChatEnhanceServiceImpl.java#L213-L249","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Wait until the daily window resets or ask an admin to clear the Redis key <redisPrefix><uid> if the quota is wrong.","Avoid client-side retry loops that re-call saveFile after a failure without confirming the upload did not land.","If the quota is too low for the use case, raise dailyUploadNum on the relevant ChatFileLimitEnum constant.","Verify distinct users are not sharing one uid/token, which would conflate their counters."],"exampleFix":"// before\nfor (File f : files) { saveFile(...); } // partial failure leaves counter incremented, retries exceed quota\n// after\nlong remaining = dailyUploadNum - counter.get();\nif (files.length > remaining) {\n    throw new IllegalStateException(\"Only \" + remaining + \" uploads left today\");\n}\nfor (File f : files) { saveFile(...); }","handlingStrategy":"try-catch","validationCode":"String redisKey = ChatFileLimitEnum.DOCUMENT.getRedisPrefix() + uid;\nlong used = redissonClient.getAtomicLong(redisKey).get();\nif (used >= ChatFileLimitEnum.DOCUMENT.getDailyUploadNum()) {\n    throw new IllegalStateException(\"Daily upload quota exhausted\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    chatEnhanceService.saveFile(uid, fileName, fileUrl, fileSize, businessType);\n} catch (BusinessException e) {\n    if (ResponseEnum.LONG_CONTENT_FILE_NUM_OUT_LIMIT.equals(e.getResponseEnum())) {\n        // show remaining-quota message; do not auto-retry\n    }\n}","preventionTips":["Display remaining daily quota to users before they attempt uploads.","Never retry saveFile in a loop after a failure without checking the counter.","Ensure each user has a unique uid so counters are not shared."],"tags":["rate-limit","redis","java","quota"],"backgroundTag":"rate-limit-exceeded","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}