{"record":{"id":"b9f7da4be281043c","repo":"iflytek/astron-agent","slug":"current-conversation-window-is-unavailable","errorCode":null,"errorMessage":"Current conversation window is unavailable","messagePattern":"Current conversation window is unavailable","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/controller/chat/ChatMessageController.java","lineNumber":158,"sourceCode":"\n        return ValidationResult.valid();\n    }\n\n    /**\n     * Validate chat context\n     *\n     * @param chatId Chat ID\n     * @param sseId Server-sent events ID\n     * @param sseEmitter Server-sent events emitter\n     * @return Valid chat context or null\n     */\n    private ChatContext validateChatContext(Long chatId, Long requestId, String sseId, SseEmitter sseEmitter) {\n        String uid = RequestContextUtil.getUID();\n\n        ChatList chatList = chatListDataService.findByUidAndChatId(uid, chatId);\n        if (chatList == null) {\n            log.warn(\"Chat window is unavailable or illegal access, sseId: {}, uid: {}, chatId: {}\", sseId, uid, chatId);\n            SseEmitterUtil.sendError(sseEmitter, \"Current conversation window is unavailable\");\n            SseEmitterUtil.sendEndAndComplete(sseEmitter);\n            return null;\n        }\n\n        Integer botId = chatList.getBotId();\n        if (chatBotDataService.botIsDeleted(botId.longValue())) {\n            log.warn(\"Current conversation window assistant has been deleted, sseId: {}, uid: {}, chatId: {}, botId: {}\", sseId, uid, chatId, botId);\n            SseEmitterUtil.sendError(sseEmitter, \"Current conversation window assistant has been deleted\");\n            SseEmitterUtil.sendEndAndComplete(sseEmitter);\n            return null;\n        }\n\n        // Re-answering requires validating the legitimacy of question ID\n        if (requestId != null) {\n            ChatReqRecords chatReqRecord = chatDataService.findRequestById(requestId);\n            if (chatReqRecord == null) {\n                log.warn(\"Record for re-answer request does not exist, sseId: {}, requestId: {}\", sseId, requestId);\n                SseEmitterUtil.sendError(sseEmitter, \"Record for re-answer request does not exist\");","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/controller/chat/ChatMessageController.java#L140-L176","documentation":"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.","triggerScenarios":"Calling the chat message endpoint with a chatId that does not exist in chat_list for the authenticated user (findByUidAndChatId returns null).","commonSituations":"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.","solutions":["Refresh the chat list in the UI and open a valid conversation before sending","Verify the chatId belongs to the currently authenticated user and space","Re-create the conversation if it was deleted"],"exampleFix":"// before\nsend(chatId, text); // chatId from stale state\n// after\nconst chats = await fetchChatList();\nif (!chats.some(c => c.id === chatId)) { chatId = (await createChat()).id; }\nsend(chatId, text);","handlingStrategy":"validation","validationCode":"const chat = await getChatList().then(l => l.find(c => c.id === chatId));\nif (!chat) { refreshChatList(); return; }","typeGuard":"function isOwnedChat(chatId, chats) { return Array.isArray(chats) && chats.some(c => c.id === chatId); }","tryCatchPattern":null,"preventionTips":["Refresh chat list after deletions","Never persist chatIds across users/sessions","Treat not-found as 'conversation gone' and redirect to chat list"],"tags":["sse","authorization","chat","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}