iflytek/astron-agent · error
CHAT_REQ_ERROR
CHAT_REQ_ERROR
Error message
CHAT_REQ_ERROR
What it means
TalkAgentServiceImpl.saveHistory validates that the given chatId resolves to an existing chat tree. It returns ResponseEnum.CHAT_REQ_ERROR when the chatId is blank/unknown or when no ChatTreeIndex rows exist for it. This is an API-level error code telling the client the chat request cannot be processed because the conversation record is missing.
Solutions
- Have the client create a new conversation (fresh chatId) instead of reusing the missing one.
- Check chat_list / chat_tree_index tables to confirm whether the chatId was deleted or never created.
- Ensure the frontend sends the current chatId from the create-conversation response, not a cached one.
- Verify ordering: chat tree index must be persisted before history save is invoked.
Defensive patterns
Strategy: validation
Validate before calling
// client-side before saving history
const chat = await getConversation(chatId);
if (!chat || chat.deleted) { startNewConversation(); return; } Type guard
function hasChatTreeIndex(list) {
return Array.isArray(list) && list.length > 0;
} Try / catch
ResponseEnum result = talkAgentService.saveHistory(req);
if (result == ResponseEnum.CHAT_REQ_ERROR) {
log.warn("chat missing, creating new conversation");
chatId = conversationService.create(uid);
} Prevention
- Always take chatId from the create-conversation response, never from stale client cache.
- Create the chat tree index atomically with the first message.
- Reconcile deleted conversations in the client on 404/CHAT_REQ_ERROR.
- Log chatId + uid on failure for supportability.
When it happens
Trigger: saveHistory called with a chatId that has no rows in chat_tree_index (findChatTreeIndexByChatIdOrderById returns an empty list), or an invalid chatId rejected by the earlier guard.
Common situations: Client sends a stale/deleted conversation ID after the chat was removed; race where the first message is saved before the chat tree index is created; ID truncation or wrong ID field sent by the frontend; cross-user access with a fabricated chatId.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Chat ID cannot be empty
- CHAT_REQ_NOT_BELONG_ERROR
- ENG_PROTOCOL_VALIDATE_ERROR
- LONG_CONTENT_CHAT_ID_ERROR
- LONG_CONTENT_MISS_FILE_INFO
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/b723310fe59d0a8b.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/bot/impl/TalkAgentServiceImpl.java:79
SIGNATURE_URL, "GET", config.getSparkVirtualManApiKey(), config.getSparkVirtualManApiSecret());
}
@Override
public ResponseEnum saveHistory(String uid, TalkAgentHistoryDto talkAgentHistoryDto) {
Long chatId = talkAgentHistoryDto.getChatId();
Integer clientType = talkAgentHistoryDto.getClientType();
String req = talkAgentHistoryDto.getReq();
String resp = talkAgentHistoryDto.getResp();
String sid = talkAgentHistoryDto.getSid();
if (chatId == null) {
return ResponseEnum.CHAT_REQ_ERROR;
}
// get latest chatId
List<ChatTreeIndex> chatTreeIndexList = chatListDataService.findChatTreeIndexByChatIdOrderById(chatId);
if (chatTreeIndexList.isEmpty()) {
log.warn("chatTreeList is empty, chatId:{}, sid:{}", chatId, sid);
return ResponseEnum.CHAT_REQ_ERROR;
}
Long lastChatId = chatTreeIndexList.getFirst().getChildChatId();
// check chatId available
ChatList chatList = chatListDataService.findByUidAndChatId(uid, lastChatId);
if (chatList == null) {
log.warn("Chat window is unavailable or illegal access,uid: {}, chatId: {}", uid, chatId);
return ResponseEnum.CHAT_REQ_NOT_BELONG_ERROR;
}
// record request
chatId = lastChatId;
ChatReqRecords chatReqRecords = new ChatReqRecords();
chatReqRecords.setChatId(chatId);
chatReqRecords.setUid(uid);
chatReqRecords.setMessage(req);
chatReqRecords.setClientType(clientType);
chatReqRecords.setCreateTime(LocalDateTime.now());
chatReqRecords.setUpdateTime(LocalDateTime.now());
chatReqRecords.setNewContext(1);View on GitHub (pinned to 5e758547a8)