{"record":{"id":"05f30f06b4c33252","repo":"iflytek/astron-agent","slug":"long-content-chat-id-error","errorCode":"LONG_CONTENT_CHAT_ID_ERROR","errorMessage":"LONG_CONTENT_CHAT_ID_ERROR","messagePattern":"LONG_CONTENT_CHAT_ID_ERROR","errorType":"exception","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/controller/chat/ChatEnhanceController.java","lineNumber":72,"sourceCode":"     * @return Result of saving the file, including file ID or error information\n     */\n    @PostMapping(path = \"/save-file\")\n    @Operation(summary = \"Save File\")\n    public ApiResult<String> saveFile(@RequestBody ChatEnhanceSaveFileVo vo) {\n        String uid = RequestContextUtil.getUID();\n        // Get the latest chat_id\n        if (ObjectUtil.isNotEmpty(vo.getChatId()) && vo.getChatId() != 0) {\n            Long chatId = vo.getChatId();\n            // Get the latest chat_id\n            List<ChatTreeIndex> chatTreeIndexList = chatListDataService.findChatTreeIndexByChatIdOrderById(chatId);\n            if (chatTreeIndexList.isEmpty()) {\n                return ApiResult.error(ResponseEnum.DATA_NOT_FOUND);\n            }\n            chatId = chatTreeIndexList.getFirst().getChildChatId();\n            ChatList chatList = chatListDataService.findByUidAndChatId(uid, chatId);\n            if (chatList == null || chatList.getEnable() == 0) {\n                log.error(\"User: {} uploaded file with incorrect chatId information: {}\", uid, vo);\n                throw new BusinessException(ResponseEnum.LONG_CONTENT_CHAT_ID_ERROR);\n            }\n            // Set the latest chatId\n            vo.setChatId(chatId);\n        }\n        Map<String, String> saveFileReq = chatEnhanceService.saveFile(uid, vo);\n        String fileId = saveFileReq.get(\"file_id\");\n        String errorMsg = saveFileReq.get(\"error_msg\");\n        if (StringUtils.isNotBlank(fileId)) {\n            return ApiResult.success(fileId);\n        }\n        // If fileId is empty, return error message\n        return ApiResult.error(-1, errorMsg);\n    }\n\n    /**\n     * Unbind file from ChatId\n     *\n     * @param longFileDto Object containing file ID and optional link ID as well as parameter name","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/controller/chat/ChatEnhanceController.java#L54-L90","documentation":"saveFile resolves the latest child chatId from the chat tree and validates that the resulting chat exists and is enabled for the user; if chatList is missing or enable==0 it throws BusinessException(LONG_CONTENT_CHAT_ID_ERROR). It signals the supplied chat/file context points to a nonexistent or disabled conversation.","triggerScenarios":"Uploading a long-content file where vo's chatId resolves through chatTreeIndex to a chatId whose ChatList record is null or has enable==0 for this uid — e.g. chat deleted or disabled after tree lookup.","commonSituations":"Client caches an old chatId after the conversation was deleted/disabled; two tabs where one deletes the chat; race between chat deletion and file upload; cross-user chatId reuse (uid mismatch).","solutions":["Refresh the chat list on the client and retry with a valid, enabled chatId","Verify the chat exists and enable==1 for the authenticated uid before uploading","Check logs ('uploaded file with incorrect chatId information') for the uid/vo involved","Handle DATA_NOT_FOUND vs LONG_CONTENT_CHAT_ID_ERROR distinctly in the client to prompt recreation of the conversation"],"exampleFix":"// before\nawait chatApi.saveFile({ chatId: staleChatId, ... });\n// after\nconst chat = await chatApi.getChat(uid, chatId);\nif (!chat || chat.enable === 0) { chatId = await createOrPickActiveChat(); }\nawait chatApi.saveFile({ chatId, ... });","handlingStrategy":"validation","validationCode":"const chat = await getChat(uid, chatId); const usable = chat && chat.enable === 1;","typeGuard":"const isActiveChat = (c: Chat | null | undefined): c is Chat => !!c && c.enable === 1;","tryCatchPattern":"try { await chatApi.saveFile(vo); } catch (e) { if (e.code === LONG_CONTENT_CHAT_ID_ERROR) { await refreshChatList(); showToast('Conversation unavailable, please select another'); } }","preventionTips":["Re-fetch chat state before file operations instead of caching chatId","Invalidate client caches when a chat is deleted/disabled","Keep uid-scoped checks consistent between tree lookup and ChatList lookup"],"tags":["validation","chat","file-upload","state"],"backgroundTag":"entity-not-found","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"}