iflytek/astron-agent · error · BusinessException

DATA_NOT_FOUND

DATA_NOT_FOUND

Error message

DATA_NOT_FOUND

What it means

DATA_NOT_FOUND is thrown in unbindFile when chatListDataService.findChatTreeIndexByChatIdOrderById(chatId) returns an empty list, meaning no chat tree index rows exist for the given chatId. The controller uses this index to resolve the latest child chatId; without any rows it cannot proceed and reports the chat as not found.

Solutions

  1. Verify the chatId exists by listing chats for the user before calling unbind
  2. Refresh the chatId from the chat list API (stale/deleted chats return this error)
  3. Check you are hitting the correct environment/database for that chatId
  4. Confirm the chat tree index was created (chat went through the long-content flow)

Example fix

// before
unbindFile({ chatId: 999999, fileId: "f1" }) // chat never created
// after
const chats = await listChats();
const valid = chats.find(c => c.chatId === 999999);
if (valid) await unbindFile({ chatId: 999999, fileId: "f1" });
Defensive patterns

Strategy: validation

Validate before calling

const chats = await listChats(uid); if (!chats.some(c => c.chatId === chatId)) throw new Error('chatId does not exist');

Try / catch

try { await unbindFile(dto); } catch (e) { if (e.code === 'DATA_NOT_FOUND') { await refreshChatList(); } else throw e; }

Prevention

When it happens

Trigger: Calling unbind-file with a chatId that has no ChatTreeIndex rows — typically a nonexistent chatId, a chatId belonging to a different environment/database, or a chat whose tree index was already deleted.

Common situations: Client caching an old chatId after the chat was deleted; using the parent/summary chat id instead of the child id in flows where the index was never created; pointing a test client at a fresh database.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/controller/chat/ChatEnhanceController.java:111

     */
    @Operation(summary = "Unbind file's FileId and ChatId")
    @PostMapping(path = "unbind-file")
    public ApiResult<Object> unbindFile(@RequestBody LongFileDto longFileDto) {
        if (StringUtils.isBlank(longFileDto.getChatId())) {
            throw new BusinessException(ResponseEnum.LONG_CONTENT_MISS_FILE_INFO);
        }
        Long chatId = Long.valueOf(longFileDto.getChatId());
        String fileId = longFileDto.getFileId();
        String linkIdString = longFileDto.getLinkId();

        if (StringUtils.isBlank(fileId) && StringUtils.isBlank(linkIdString)) {
            throw new BusinessException(ResponseEnum.LONG_CONTENT_MISS_FILE_INFO);
        }
        String uid = RequestContextUtil.getUID();
        // Get the latest chat_id
        List<ChatTreeIndex> chatTreeIndexList = chatListDataService.findChatTreeIndexByChatIdOrderById(chatId);
        if (chatTreeIndexList.isEmpty()) {
            throw new BusinessException(ResponseEnum.DATA_NOT_FOUND);
        }
        chatId = chatTreeIndexList.getFirst().getChildChatId();
        ChatList chatList = chatListDataService.findByUidAndChatId(uid, chatId);
        if (chatList == null || chatList.getEnable() == 0) {
            throw new BusinessException(ResponseEnum.LONG_CONTENT_CHAT_ID_ERROR);
        }
        // Logical deletion of chatFileReq (unbind file from chatID)
        if (StringUtils.isNotBlank(linkIdString)) {
            ChatFileUser chatFileUser = chatEnhanceService.findById(Long.valueOf(linkIdString), uid);
            if (chatFileUser == null || chatFileUser.getFileId() == null) {
                throw new BusinessException(ResponseEnum.FILE_NOT_PROCESS);
            }
            fileId = chatFileUser.getFileId();
        }
        chatEnhanceService.delete(fileId, chatId, uid);

        if (StrUtil.isNotEmpty(longFileDto.getParamName())) {
            List<BotChatFileParam> oneByChatIdAndNameList = chatDataService.findAllBotChatFileParamByChatIdAndNameAndIsDelete(chatId, longFileDto.getParamName(), 0);

View on GitHub (pinned to 5e758547a8)