iflytek/astron-agent · error
Chat ID cannot be empty
Error message
Chat ID cannot be empty
What it means
ChatMessageController.chat resolves the latest chat_id from ChatTreeIndex records via chatListDataService.findChatTreeIndexByChatIdOrderById. When the lookup returns an empty list, it logs 'chatId is empty', sends an SSE error message 'Chat ID cannot be empty' to the client stream, completes the emitter, and aborts. It means no chat tree history exists for the supplied chatId, so the conversation cannot continue.
Solutions
- Verify the chatId exists in the chat tree index table for the requesting user/space
- Check for a race: ensure the first message's tree-index row is persisted before sending follow-up messages
- Handle the SSE 'Chat ID cannot be empty' event on the frontend by starting a new conversation
- Confirm the client passes the correct chatId (root/current) field, not sseId or botId
- Guard against stale local state — refresh the chat list before resuming an old conversation
Defensive patterns
Strategy: validation
Validate before calling
List<ChatTreeIndex> idx = chatListDataService.findChatTreeIndexByChatIdOrderById(chatId);
if (idx == null || idx.isEmpty()) { emitter error + return; } Try / catch
// server already emits SSE error; client side:
es.onmessage = (e) => { if (e.data.includes("Chat ID cannot be empty")) startNewConversation(); }; Prevention
- Refresh chat state before resuming an old conversation
- Ensure the first message persists tree-index rows before follow-ups
- Verify the client sends the correct chatId field
- Handle SSE error events gracefully by starting a new chat
When it happens
Trigger: SSE chat request with a chatId that has no rows in the chat tree index table: stale/deleted conversation, fabricated chatId, or a chatId from a different space/user than the one queried.
Common situations: Frontend resuming a conversation that was deleted server-side; race where chat history persistence hasn't completed before the next message is sent; cross-environment reuse of chat IDs (test data in prod); wrong chatId field passed instead of the root id.
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
- Please enter chat content
- Please enter chat content
- LONG_CONTENT_CHAT_ID_ERROR
- LONG_CONTENT_MISS_FILE_INFO
- PARAMS_ERROR
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/f9c457d98d07bddb.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/controller/chat/ChatMessageController.java:96
@RequestParam(required = false) String fileUrl,
@RequestParam(required = false) String workflowOperation,
@RequestParam(required = false) String workflowVersion) {
String sseId = RandomUtil.randomString(8);
SseEmitter sseEmitter = SseEmitterUtil.createSseEmitter();
log.info("Establishing SSE connection, sseId: {}, chatId: {}", sseId, chatId);
// Validate before any conversation lookup so invalid input has no downstream side effects.
ValidationResult validation = validateChatRequest(chatId, text, sseId, sseEmitter);
if (!validation.isValid()) {
return sseEmitter;
}
// Get the latest chat_id
List<ChatTreeIndex> chatTreeIndexList = chatListDataService.findChatTreeIndexByChatIdOrderById(chatId);
if (chatTreeIndexList.isEmpty()) {
log.warn("chatId is empty, sseId: {}", sseId);
SseEmitterUtil.sendError(sseEmitter, "Chat ID cannot be empty");
SseEmitterUtil.sendEndAndComplete(sseEmitter);
return sseEmitter;
}
Long lastChatId = chatTreeIndexList.getFirst().getChildChatId();
// Preserve validation of the resolved child ID in case stored tree data is incomplete.
ValidationResult resolvedChatValidation = validateChatRequest(lastChatId, text, sseId, sseEmitter);
if (!resolvedChatValidation.isValid()) {
return sseEmitter;
}
// Validate chat window and assistant status
ChatContext chatContext = validateChatContext(lastChatId, null, sseId, sseEmitter);
if (chatContext == null) {
return sseEmitter;
}
return processChatRequest(chatContext, text, fileUrl, sseEmitter, sseId, workflowOperation, workflowVersion);View on GitHub (pinned to 5e758547a8)