{"record":{"id":"0b57403e3cb0fa48","repo":"iflytek/astron-agent","slug":"create-bot-failed-0b5740","errorCode":"CREATE_BOT_FAILED","errorMessage":"CREATE_BOT_FAILED","messagePattern":"CREATE_BOT_FAILED","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/BotMaasServiceImpl.java","lineNumber":114,"sourceCode":"            return createFromExportedTemplate(uid, maasDuplicate, request);\n        }\n        return createFromOfficialTemplate(uid, maasDuplicate, request);\n    }\n\n    private BotInfoDto createFromOfficialTemplate(String uid, MaasDuplicate maasDuplicate, HttpServletRequest request) {\n        Long spaceId = SpaceInfoUtil.getSpaceId();\n        // Create an event, consumed by /maasCopySynchronize\n        Long maasId = maasDuplicate.getMaasId();\n        UserLangChainInfo userLangChainInfo = userLangChainDataService.selectByMaasId(maasId);\n        if (Objects.isNull(userLangChainInfo)) {\n            log.info(\"----- Xinghuo did not find Astron workflow: {}\", JSONObject.toJSONString(userLangChainInfo));\n            throw new BusinessException(ResponseEnum.BOT_NOT_EXIST);\n        }\n        redissonClient.getBucket(MaasUtil.generatePrefix(uid, Math.toIntExact(userLangChainInfo.getId()))).set(userLangChainInfo.getId().toString(), Duration.ofSeconds(60));\n        BotInfoDto botInfoDto = botService.insertWorkflowBot(uid, maasDuplicate, spaceId, BotVersionEnum.WORKFLOW.getVersion());\n        // Check if response is successful\n        if (botInfoDto == null) {\n            throw new BusinessException(ResponseEnum.CREATE_BOT_FAILED);\n        }\n        // Copy a new workflow for the assistant\n        JSONObject res = maasUtil.copyWorkFlow(maasDuplicate.getMaasId(), request, BotVersionEnum.WORKFLOW.getVersion(), Long.valueOf(botInfoDto.getBotId()), null);\n        if (Objects.isNull(res) || res.isEmpty()) {\n            throw new BusinessException(ResponseEnum.CREATE_BOT_FAILED);\n        }\n        Integer botId = botInfoDto.getBotId();\n        botService.addMaasInfo(uid, res, botId, spaceId);\n        botInfoDto.setFlowId(res.getJSONObject(\"data\").getLong(\"id\"));\n        return botInfoDto;\n    }\n\n    private BotInfoDto createFromExportedTemplate(String uid, MaasDuplicate maasDuplicate, HttpServletRequest request) {\n        Long templateId = maasDuplicate.getTemplateId();\n        if (templateId == null) {\n            throw new BusinessException(ResponseEnum.PARAMETER_ERROR);\n        }\n","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/BotMaasServiceImpl.java#L96-L132","documentation":"BusinessException(ResponseEnum.CREATE_BOT_FAILED) thrown in BotMaasServiceImpl.createFromOfficialTemplate when botService.insertWorkflowBot returns null after creating a workflow bot record. It means the bot row could not be persisted, so the official-template instantiation must abort before copying the workflow. This is a service-layer persistence failure, not a client input problem.","triggerScenarios":"Calling createFromTemplate for an official (maas) template where insertWorkflowBot(uid, maasDuplicate, spaceId, WORKFLOW version) returns null — e.g. the underlying bot insert fails silently or a duplicate/conflicting bot record prevents creation.","commonSituations":"Database constraint violations swallowed by the insert service, bot-service upstream outage, invalid spaceId for the user, or partial state left from a previous failed template-creation attempt with the same maasId.","solutions":["Inspect botService.insertWorkflowBot to find why it returns null (check DB logs for failed insert on bot_info) and fix the root cause there","Verify spaceId is valid and the user has permission to create bots in that space","Check for leftover rows from a prior failed attempt (same uid/maasId) and clean them up","Retry the create-from-template call after confirming the database and bot service are healthy"],"exampleFix":"// before (insertWorkflowBot swallows the cause)\nBotInfoDto botInfoDto = botService.insertWorkflowBot(uid, maasDuplicate, spaceId, BotVersionEnum.WORKFLOW.getVersion());\nif (botInfoDto == null) { throw new BusinessException(ResponseEnum.CREATE_BOT_FAILED); }\n// after (log the cause before throwing)\nBotInfoDto botInfoDto = botService.insertWorkflowBot(uid, maasDuplicate, spaceId, BotVersionEnum.WORKFLOW.getVersion());\nif (botInfoDto == null) {\n    log.error(\"insertWorkflowBot returned null, uid={}, maasId={}, spaceId={}\", uid, maasDuplicate.getMaasId(), spaceId);\n    throw new BusinessException(ResponseEnum.CREATE_BOT_FAILED);\n}","handlingStrategy":"try-catch","validationCode":"if (spaceId == null || spaceId <= 0) { throw new IllegalArgumentException(\"valid spaceId required\"); }","typeGuard":"BotInfoDto bot = botService.insertWorkflowBot(...);\nif (bot == null || bot.getBotId() == null) { /* handle creation failure */ }","tryCatchPattern":"try {\n    botMaasService.createFromTemplate(uid, req, httpRequest);\n} catch (BusinessException e) {\n    if (ResponseEnum.CREATE_BOT_FAILED.getCode().equals(e.getCode())) {\n        // surface 'bot creation failed, please retry' and check bot service/DB health\n    }\n    throw e;\n}","preventionTips":["Monitor insertWorkflowBot null returns with alerts","Ensure spaceId validity and user permission before creating bots","Clean up partial rows from failed creation attempts","Keep bot insert failures logged with root cause, not swallowed"],"tags":["bot-creation","persistence","workflow-template"],"backgroundTag":"database-write-failed","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"}