{"record":{"id":"f07ef481f520e766","repo":"iflytek/astron-agent","slug":"long-content-miss-file-info","errorCode":"LONG_CONTENT_MISS_FILE_INFO","errorMessage":"LONG_CONTENT_MISS_FILE_INFO","messagePattern":"LONG_CONTENT_MISS_FILE_INFO","errorType":"exception","errorClass":"BusinessException","httpStatus":null,"severity":"warning","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/controller/chat/ChatEnhanceController.java","lineNumber":98,"sourceCode":"        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\n     * @return Operation result object\n     * @throws BusinessException Thrown when file information is missing or invalid\n     */\n    @Operation(summary = \"Unbind file's FileId and ChatId\")\n    @PostMapping(path = \"unbind-file\")\n    public ApiResult<Object> unbindFile(@RequestBody LongFileDto longFileDto) {\n        if (StringUtils.isBlank(longFileDto.getChatId())) {\n            throw new BusinessException(ResponseEnum.LONG_CONTENT_MISS_FILE_INFO);\n        }\n        Long chatId = Long.valueOf(longFileDto.getChatId());\n        String fileId = longFileDto.getFileId();\n        String linkIdString = longFileDto.getLinkId();\n\n        if (StringUtils.isBlank(fileId) && StringUtils.isBlank(linkIdString)) {\n            throw new BusinessException(ResponseEnum.LONG_CONTENT_MISS_FILE_INFO);\n        }\n        String uid = RequestContextUtil.getUID();\n        // Get the latest chat_id\n        List<ChatTreeIndex> chatTreeIndexList = chatListDataService.findChatTreeIndexByChatIdOrderById(chatId);\n        if (chatTreeIndexList.isEmpty()) {\n            throw new BusinessException(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            throw new BusinessException(ResponseEnum.LONG_CONTENT_CHAT_ID_ERROR);","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/controller/chat/ChatEnhanceController.java#L80-L116","documentation":"unbindFile validates the unbind request and throws BusinessException(LONG_CONTENT_MISS_FILE_INFO) when chatId is blank (and, per the following check, when both fileId and linkId are blank). The request lacks the minimum identifying information needed to unbind a file from a conversation.","triggerScenarios":"POST /unbind-file with a LongFileDto whose chatId is empty/null/whitespace, or with neither fileId nor linkId supplied.","commonSituations":"Frontend builds the DTO from state that was never populated (file not yet bound); API consumers omit optional-looking fields; stale client state after chat deletion wipes ids.","solutions":["Ensure chatId is always set in the request body before calling unbind-file","Provide either fileId or linkId along with chatId (the endpoint requires at least one)","Validate the DTO client-side and show a form error instead of hitting the API","Catch BusinessException and map LONG_CONTENT_MISS_FILE_INFO to a 'missing file information' user message"],"exampleFix":"// before\nawait chatApi.unbindFile({ chatId });\n// after\nif (!chatId || (!fileId && !linkId)) { showError('chatId and (fileId or linkId) are required'); return; }\nawait chatApi.unbindFile({ chatId, fileId, linkId });","handlingStrategy":"validation","validationCode":"const canUnbind = Boolean(chatId && chatId.trim()) && (Boolean(fileId) || Boolean(linkId));","typeGuard":"const hasFileRef = (d: LongFileDto): boolean => !!(d.chatId?.trim() && (d.fileId || d.linkId));","tryCatchPattern":"try { await chatApi.unbindFile(dto); } catch (e) { if (e.code === LONG_CONTENT_MISS_FILE_INFO) showToast('chatId and fileId/linkId are required'); }","preventionTips":["Validate the DTO before sending; never send blank chatId","Make required fields explicit in the API contract/OpenAPI schema","Populate fileId at bind time so unbind always has a reference"],"tags":["validation","chat","request","missing-field"],"backgroundTag":"empty-required-field","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"}