{"record":{"id":"6f7bb353789ee101","repo":"iflytek/astron-agent","slug":"params-error-6f7bb3","errorCode":"PARAMS_ERROR","errorMessage":"PARAMS_ERROR","messagePattern":"PARAMS_ERROR","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/controller/chat/ChatMessageController.java","lineNumber":459,"sourceCode":"        } catch (Exception e) {\n            log.error(\"Bot debug error, sseId: {}\", sseId, e);\n            SseEmitterUtil.completeWithError(sseEmitter, \"Chat service exception: \" + e.getMessage());\n            return sseEmitter;\n        }\n    }\n\n    /**\n     * Clear chat history\n     */\n    @GetMapping(path = \"/clear\")\n    @Operation(summary = \"Clear chat history\")\n    public ApiResult<ChatListCreateResponse> clear(Integer botId, Long chatId) {\n        String uid = RequestContextUtil.getUID();\n        if (uid == null) {\n            throw new BusinessException(ResponseEnum.LOGIN_INFO_ERROR);\n        }\n        if (chatId == null) {\n            throw new BusinessException(ResponseEnum.PARAMS_ERROR);\n        }\n        ChatBotBase botBase = chatBotDataService.findById(botId).orElse(null);\n        if (botBase == null) {\n            throw new BusinessException(ResponseEnum.PARAMS_ERROR);\n        }\n        return ApiResult.success(botChatService.clear(chatId, uid, botId, botBase));\n    }\n}\n","sourceCodeStart":441,"sourceCodeEnd":468,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/controller/chat/ChatMessageController.java#L441-L468","documentation":"PARAMS_ERROR is a generic client-input validation failure thrown by the chat message controller's clear() endpoint. It fires when the caller's chatId is null, meaning the request did not identify which chat list to clear. The backend refuses to proceed rather than guessing a chat.","triggerScenarios":"Calling the clear endpoint (ChatMessageController.clear) with request params missing chatId, or a client serializing chatId as null after a failed chat creation.","commonSituations":"Frontend clears a conversation before the chat list was created (chatId not yet assigned); stale UI state pointing at a deleted/never-created chat; API consumers calling the endpoint directly without chatId.","solutions":["Ensure the client sends chatId in the request before calling clear","Check the calling code obtains chatId from the chat creation/list API response","Log the request payload and verify JSON field name matches (chatId, not chat_id)","Guard in UI: disable 'clear chat' until a chat exists"],"exampleFix":"// before\nawait api.post('/chat/clear', { botId });\n// after\nif (!chatId) throw new Error('chatId required');\nawait api.post('/chat/clear', { botId, chatId });","handlingStrategy":"validation","validationCode":"if (chatId == null) throw new IllegalArgumentException('chatId is required');","typeGuard":"if (typeof chatId === 'number' && chatId > 0) { /* safe to call */ }","tryCatchPattern":"try { await clearChat(botId, chatId); } catch (e) { if (e.code === 'PARAMS_ERROR') refreshChatState(); }","preventionTips":["Never call clear before chat creation completes","Validate required params client-side","Keep chatId in a single source of truth (store)"],"tags":["validation","request-params","chat"],"backgroundTag":"null-argument","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"}