{"record":{"id":"cae00e683b727480","repo":"iflytek/astron-agent","slug":"bot-chain-submit-error","errorCode":"BOT_CHAIN_SUBMIT_ERROR","errorMessage":"BOT_CHAIN_SUBMIT_ERROR","messagePattern":"BOT_CHAIN_SUBMIT_ERROR","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/commons/src/main/java/com/iflytek/astron/console/commons/service/workflow/impl/WorkflowBotChatServiceImpl.java","lineNumber":124,"sourceCode":"    public void chatWorkflowBot(ChatBotReqDto chatBotReqDto, SseEmitter sseEmitter, String sseId, String workflowOperation, String workflowVersion) {\n        String uid = chatBotReqDto.getUid();\n        Long chatId = chatBotReqDto.getChatId();\n        String ask = chatBotReqDto.getAsk();\n        String url = chatBotReqDto.getUrl();\n        Integer botId = chatBotReqDto.getBotId();\n\n        if (StrUtil.isBlank(ask)) {\n            log.warn(\"Rejecting workflow chat request with empty user input, uid: {}, chatId: {}, botId: {}\",\n                    uid, chatId, botId);\n            throw new BusinessException(ResponseEnum.PARAMETER_ERROR);\n        }\n\n        JSONObject inputs = new JSONObject();\n        inputs.put(\"AGENT_USER_INPUT\", ask);\n\n        UserLangChainInfo userLangChainInfo = userLangChainDataService.findOneByBotId(botId);\n        if (userLangChainInfo == null) {\n            throw new BusinessException(ResponseEnum.BOT_CHAIN_SUBMIT_ERROR);\n        }\n        String flowId = userLangChainInfo.getFlowId();\n        String effectiveWorkflowVersion = resolveWorkflowVersion(botId, flowId, workflowVersion);\n        // Record current question\n        ChatReqRecords chatReqRecords = new ChatReqRecords();\n        chatReqRecords.setChatId(chatId);\n        chatReqRecords.setUid(uid);\n        chatReqRecords.setMessage(ask);\n        chatReqRecords.setClientType(0);\n        chatReqRecords.setCreateTime(LocalDateTime.now());\n        chatReqRecords.setUpdateTime(LocalDateTime.now());\n        chatReqRecords.setNewContext(1);\n        chatReqRecords = chatDataService.createRequest(chatReqRecords);\n        Long reqId = chatReqRecords.getId();\n\n        JSONObject extraInputs = JSONObject.parseObject(userLangChainInfo.getExtraInputs());\n\n        // Handle multi-file parameter type","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/commons/src/main/java/com/iflytek/astron/console/commons/service/workflow/impl/WorkflowBotChatServiceImpl.java#L106-L142","documentation":"BusinessException with code BOT_CHAIN_SUBMIT_ERROR thrown by chatWorkflowBot when userLangChainDataService.findOneByBotId(botId) returns null — i.e. no workflow (LangChain) binding exists for the bot, so there is no flowId to submit the chat request to.","triggerScenarios":"Sending a chat request to a botId that has no associated workflow record: the bot was created as a basic bot, the workflow binding was deleted, the wrong botId was passed, or the binding row is missing/corrupt in the database.","commonSituations":"Client caching a stale botId after the bot was deleted or converted; bots imported/copied without their workflow binding; race between bot deletion and an in-flight chat request; environment mismatch where the bot exists in one DB but its chain record is in another.","solutions":["Verify the botId is correct and that the bot is actually a workflow-type bot.","Re-fetch the bot list to clear stale botIds and retry with a valid one.","Re-publish/bind the workflow to the bot so a UserLangChainInfo record with a flowId exists.","Check the database for a missing user_lang_chain_info row for this botId and restore the binding if it was lost."],"exampleFix":"// before: chat with any bot id\nawait chatWorkflowBot({ botId: someId, ask });\n// after: only workflow bots support this endpoint\nconst bot = await getBot(someId);\nif (!bot || bot.type !== 'workflow') throw new Error('Bot has no workflow bound');\nawait chatWorkflowBot({ botId: someId, ask });","handlingStrategy":"validation","validationCode":"const bot = await getBot(botId);\nif (!bot || !bot.flowId) throw new Error('Bot has no workflow binding; cannot chat');","typeGuard":"function isWorkflowBot(bot) { return bot != null && typeof bot.flowId === 'string' && bot.flowId.length > 0; }","tryCatchPattern":"try { await chatWorkflowBot({ botId, ask }); } catch (e) { if (e.code === 'BOT_CHAIN_SUBMIT_ERROR') { await refreshBotList(); notify('This bot has no workflow bound'); } else throw e; }","preventionTips":["Only call the workflow chat endpoint for workflow-type bots","Refresh cached botIds after bot deletion or conversion","Ensure copy/import flows also copy the workflow binding","Validate flowId exists before submitting chat"],"tags":["entity-not-found","workflow","binding","java"],"backgroundTag":"entity-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"}