iflytek/astron-agent · error

Current conversation window is unavailable

Error message

Current conversation window is unavailable

What it means

validateChatContext looks up the ChatList record for the current UID + chatId. If no record is found (chatList == null), the conversation window does not exist for this user or the access is illegal, so the controller sends 'Current conversation window is unavailable' over SSE and aborts. This enforces per-user ownership of chat windows.

Solutions

  1. Refresh the chat list in the UI and open a valid conversation before sending
  2. Verify the chatId belongs to the currently authenticated user and space
  3. Re-create the conversation if it was deleted

Example fix

// before
send(chatId, text); // chatId from stale state
// after
const chats = await fetchChatList();
if (!chats.some(c => c.id === chatId)) { chatId = (await createChat()).id; }
send(chatId, text);
Defensive patterns

Strategy: validation

Validate before calling

const chat = await getChatList().then(l => l.find(c => c.id === chatId));
if (!chat) { refreshChatList(); return; }

Type guard

function isOwnedChat(chatId, chats) { return Array.isArray(chats) && chats.some(c => c.id === chatId); }

Prevention

When it happens

Trigger: Calling the chat message endpoint with a chatId that does not exist in chat_list for the authenticated user (findByUidAndChatId returns null).

Common situations: Stale frontend referencing a deleted conversation; using another user's/space's chatId; race after conversation deletion; chatId from an old session or different environment.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

        return ValidationResult.valid();
    }

    /**
     * Validate chat context
     *
     * @param chatId Chat ID
     * @param sseId Server-sent events ID
     * @param sseEmitter Server-sent events emitter
     * @return Valid chat context or null
     */
    private ChatContext validateChatContext(Long chatId, Long requestId, String sseId, SseEmitter sseEmitter) {
        String uid = RequestContextUtil.getUID();

        ChatList chatList = chatListDataService.findByUidAndChatId(uid, chatId);
        if (chatList == null) {
            log.warn("Chat window is unavailable or illegal access, sseId: {}, uid: {}, chatId: {}", sseId, uid, chatId);
            SseEmitterUtil.sendError(sseEmitter, "Current conversation window is unavailable");
            SseEmitterUtil.sendEndAndComplete(sseEmitter);
            return null;
        }

        Integer botId = chatList.getBotId();
        if (chatBotDataService.botIsDeleted(botId.longValue())) {
            log.warn("Current conversation window assistant has been deleted, sseId: {}, uid: {}, chatId: {}, botId: {}", sseId, uid, chatId, botId);
            SseEmitterUtil.sendError(sseEmitter, "Current conversation window assistant has been deleted");
            SseEmitterUtil.sendEndAndComplete(sseEmitter);
            return null;
        }

        // Re-answering requires validating the legitimacy of question ID
        if (requestId != null) {
            ChatReqRecords chatReqRecord = chatDataService.findRequestById(requestId);
            if (chatReqRecord == null) {
                log.warn("Record for re-answer request does not exist, sseId: {}, requestId: {}", sseId, requestId);
                SseEmitterUtil.sendError(sseEmitter, "Record for re-answer request does not exist");

View on GitHub (pinned to 5e758547a8)