iflytek/astron-agent · error · BusinessException

CHAT_TREE_ERROR

CHAT_TREE_ERROR

Error message

CHAT_TREE_ERROR

What it means

createNewTreeIndexByRootChatId restarts a chat by loading the ChatTreeIndex rows for the root chatId and rebuilding a new tree. If no tree index rows exist for that rootChatId, there is nothing to restart from, so it throws CHAT_TREE_ERROR inside a transaction (which rolls back any work).

Solutions

  1. Verify the chatId passed is the tree's root chatId, not a child/branch chatId.
  2. Query chat_tree_index for the chatId to confirm rows exist before attempting a restart.
  3. Check whether a cleanup/retention job deleted the tree rows; restore or recreate the tree.
  4. Guard the UI so the restart action is only enabled for chats that actually have a branch tree.

Example fix

// before
chatRestartService.createNewTreeIndexByRootChatId(currentChatId, uid, name);
// after
List<ChatTreeIndex> tree = chatListDataService.findChatTreeIndexByChatIdOrderById(rootChatId);
if (tree.isEmpty()) {
    throw new BusinessException(ResponseEnum.CHAT_TREE_ERROR); // handle in caller before restart
}
chatRestartService.createNewTreeIndexByRootChatId(rootChatId, uid, name);
Defensive patterns

Strategy: validation

Validate before calling

List<ChatTreeIndex> tree = chatListDataService.findChatTreeIndexByChatIdOrderById(rootChatId);
boolean canRestart = tree != null && !tree.isEmpty();
if (!canRestart) {
    // disable restart or create a fresh chat instead
}

Type guard

boolean hasTree(Long rootChatId) {
    List<ChatTreeIndex> tree = chatListDataService.findChatTreeIndexByChatIdOrderById(rootChatId);
    return tree != null && !tree.isEmpty();
}

Try / catch

try {
    chatRestartService.createNewTreeIndexByRootChatId(rootChatId, uid, name);
} catch (BusinessException e) {
    if (ResponseEnum.CHAT_TREE_ERROR.equals(e.getResponseEnum())) {
        // fall back to creating a brand-new chat list
    }
}

Prevention

When it happens

Trigger: Calling createNewTreeIndexByRootChatId with a rootChatId that has no chat_tree_index rows — e.g. the chat was never branched, the tree rows were deleted, or an incorrect/non-root chatId is passed.

Common situations: Frontend passes the current (child) chatId instead of the root chatId; the conversation tree was cleaned up by a data-retention job; restarting a brand-new chat that has no branch tree; a bug elsewhere failed to persist tree index rows when the tree was created.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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

Appendix: source

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

    private ChatListDataService chatListDataService;

    @Autowired
    private ChatListService chatListService;

    /**
     * @param rootChatId Root chat ID
     * @param uid User ID
     * @param chatListName Chat list name
     * @return Returns a new chat list creation response
     * @throws BusinessException Thrown when chat tree index is empty
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public ChatListCreateResponse createNewTreeIndexByRootChatId(Long rootChatId, String uid, String chatListName) {
        // Retrieve the tree
        List<ChatTreeIndex> chatTreeIndexList = chatListDataService.findChatTreeIndexByChatIdOrderById(rootChatId);
        if (CollectionUtil.isEmpty(chatTreeIndexList)) {
            throw new BusinessException(ResponseEnum.CHAT_TREE_ERROR);
        }

        // Regenerate a chatId
        ChatListCreateResponse chatListCreateResponse = chatListService.createChatListForRestart(uid, chatListName, null, chatTreeIndexList.getFirst().getChildChatId());
        ChatTreeIndex chatTreeIndexLatest = chatTreeIndexList.getFirst();
        if (chatListCreateResponse.getId().equals(chatTreeIndexLatest.getChildChatId())) {
            return chatListCreateResponse;
        }

        ChatTreeIndex chatTreeIndex = ChatTreeIndex.builder()
                .rootChatId(chatTreeIndexLatest.getRootChatId())
                .parentChatId(chatTreeIndexLatest.getChildChatId())
                .childChatId(chatListCreateResponse.getId())
                .uid(uid)
                .build();
        chatListDataService.createChatTreeIndex(chatTreeIndex);
        return chatListCreateResponse;
    }

View on GitHub (pinned to 5e758547a8)