{"record":{"id":"1630414793d4d45a","repo":"iflytek/astron-agent","slug":"bot-chain-submit-error-163041","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/hub/src/main/java/com/iflytek/astron/console/hub/service/publish/impl/McpServiceImpl.java","lineNumber":65,"sourceCode":"                request.getBotId(), request.getServerName(), currentUid, spaceId);\n\n        Integer botId = request.getBotId();\n\n        // 1. Permission check\n        int hasPermission = chatBotBaseMapper.checkBotPermission(botId, currentUid, spaceId);\n        if (hasPermission == 0) {\n            throw new BusinessException(ResponseEnum.BOT_NOT_EXISTS);\n        }\n\n        // 2. Check if workflow protocol exists\n        UserLangChainInfo chainInfo = userLangChainInfoMapper.selectOne(\n                new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<UserLangChainInfo>()\n                        .eq(\"bot_id\", botId)\n                        .orderByDesc(\"create_time\")\n                        .last(\"LIMIT 1\"));\n        if (chainInfo == null) {\n            log.info(\"Bot workflow protocol not found: uid={}, botId={}\", currentUid, botId);\n            throw new BusinessException(ResponseEnum.BOT_CHAIN_SUBMIT_ERROR);\n        }\n\n        // 3. Content moderation (simplified here, should call moderation service in production)\n        // TODO: Call moderation service to check text and images\n        // String allText = request.getServerName() + request.getDescription() + request.getContent();\n\n        // 4. Get version name first (without releasing yet)\n        String versionName = getVersionName(botId, currentUid, spaceId);\n\n        // 5. Check if MCP with same version already exists\n        // int existCount = mcpDataMapper.checkMcpExists(botId, versionName);\n        // if (existCount > 0) {\n        // throw new BusinessException(\"MCP with this version already exists, please do not republish\");\n        // }\n\n        // 6. Register MCP and get server URL (corresponds to maasUtil.registerMcp in original project)\n        String serverUrl = registerMcpAndGetUrl(botId, request, versionName, currentUid, spaceId);\n","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/publish/impl/McpServiceImpl.java#L47-L83","documentation":"BOT_CHAIN_SUBMIT_ERROR is thrown by publishMcp when no UserLangChainInfo row (the bot's workflow/chain protocol record) can be found for the botId. The service requires the latest chain record to derive workflow context before publishing to MCP; without it the publish is aborted.","triggerScenarios":"Publishing an MCP server for a bot that was never saved/submitted as a workflow (no user_lang_chain_info row), or whose chain records were deleted; ordering by create_time DESC LIMIT 1 returns null.","commonSituations":"Publishing a plain chat/Q&A bot (non-workflow) through the MCP channel; DB cleanup or migration removed chain rows; bot created via import without completing workflow submission.","solutions":["Open the bot in the workflow editor and save/submit the workflow so a UserLangChainInfo row is created, then retry publish.","Verify user_lang_chain_info has a row for this bot_id: SELECT * FROM user_lang_chain_info WHERE bot_id=? ORDER BY create_time DESC LIMIT 1.","If the bot is not a workflow bot, use the correct publish channel for its type instead of MCP.","Restore missing chain rows from backup/migration if data loss occurred."],"exampleFix":"// before\nmcpService.publishMcp(request, uid, spaceId); // bot has no saved workflow\n// after\nUserLangChainInfo chain = userLangChainDataService.findLatestByBotId(botId);\nif (chain == null) {\n    workflowService.saveAndSubmitChain(botId, draftChain); // ensure workflow exists first\n}\nmcpService.publishMcp(request, uid, spaceId);","handlingStrategy":"validation","validationCode":"UserLangChainInfo chain = userLangChainInfoMapper.selectOne(new QueryWrapper<UserLangChainInfo>()\n    .eq(\"bot_id\", botId).orderByDesc(\"create_time\").last(\"LIMIT 1\"));\nif (chain == null) { throw new BusinessException(ResponseEnum.BOT_CHAIN_SUBMIT_ERROR); }","typeGuard":"boolean hasWorkflow = chainInfo != null;","tryCatchPattern":"try { mcpService.publishMcp(request, uid, spaceId); }\ncatch (BusinessException e) { if (e.getCode() == ResponseEnum.BOT_CHAIN_SUBMIT_ERROR) { promptUserToSaveWorkflow(); } else throw e; }","preventionTips":["Only offer MCP publishing for bots with a saved workflow.","Save/submit the workflow before entering any publish flow.","Alert users in the editor when a workflow is unsaved."],"tags":["workflow","publish","mcp","missing-record"],"backgroundTag":"record-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"}