{"record":{"id":"de7fe368511d0436","repo":"iflytek/astron-agent","slug":"bot-not-exist","errorCode":"BOT_NOT_EXIST","errorMessage":"BOT_NOT_EXIST","messagePattern":"BOT_NOT_EXIST","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":108,"sourceCode":"    private BotAIService botAIService;\n\n    @Override\n    public BotInfoDto createFromTemplate(String uid, MaasDuplicate maasDuplicate, HttpServletRequest request) {\n        if (maasDuplicate.getTemplateId() != null\n                || MaasTemplate.TEMPLATE_SOURCE_EXPORTED.equalsIgnoreCase(maasDuplicate.getTemplateSource())) {\n            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","sourceCodeStart":90,"sourceCodeEnd":126,"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#L90-L126","documentation":"Thrown by BotMaasServiceImpl.createFromOfficialTemplate when selectByMaasId(maasId) returns null, i.e. no UserLangChainInfo row in the Astron database maps to the requested MaaS template's maasId. The template-based bot creation cannot proceed because the local workflow record backing the official template is missing, so BOT_NOT_EXIST is raised before any bot record is inserted.","triggerScenarios":"Calling createFromTemplate with an official-template request whose maasId has no corresponding row in user_lang_chain_info; the template was published upstream (Xinghuu/MaaS) but never synchronized into Astron; maasId points to a workflow deleted locally; template source misrouted to the official path instead of the exported path.","commonSituations":"Template synchronization job between Xinghuu and Astron hasn't run or failed, so new official templates are unknown locally; environment mismatch (template exists in prod MaaS but the target Astron DB is a fresh/staging database); the maasId in the request is stale after the upstream template was deleted; wrong templateSource causing the official branch to run for an exported template.","solutions":["Confirm the maasId in the request actually exists upstream; if it was deleted, the template must be unpublished or re-published with a new id.","Run/verify the template sync job so the official MaaS template has a matching UserLangChainInfo row (check selectByMaasId for the given maasId).","Check the target environment's database — staging/dev DBs often lack prod template rows.","Verify maasDuplicate.getTemplateSource()/templateId routing: an exported template with null templateId wrongly falls into createFromOfficialTemplate.","Retry after sync; if data was deleted, recreate the bot from a valid template id."],"exampleFix":"// before\nUserLangChainInfo userLangChainInfo = userLangChainDataService.selectByMaasId(maasId);\nif (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// after\nUserLangChainInfo userLangChainInfo = userLangChainDataService.selectByMaasId(maasId);\nif (Objects.isNull(userLangChainInfo)) {\n    log.info(\"No local Astron workflow for maasId={}, templateId={}, source={}; attempting sync\",\n            maasId, maasDuplicate.getTemplateId(), maasDuplicate.getTemplateSource());\n    userLangChainInfo = maasTemplateSyncService.syncTemplateByMaasId(maasId); // pull missing template locally\n    if (Objects.isNull(userLangChainInfo)) {\n        throw new BusinessException(ResponseEnum.BOT_NOT_EXIST);\n    }\n}","handlingStrategy":"validation","validationCode":"// before creating from an official template, check the local mapping exists\nUserLangChainInfo info = userLangChainDataService.selectByMaasId(maasDuplicate.getMaasId());\nif (info == null) {\n    // trigger template sync or surface a clear 'template not synchronized' error to the caller\n    throw new BusinessException(ResponseEnum.BOT_NOT_EXIST);\n}","typeGuard":null,"tryCatchPattern":"try {\n    BotInfoDto bot = botMaasService.createFromTemplate(uid, maasDuplicate, request);\n} catch (BusinessException e) {\n    if (\"BOT_NOT_EXIST\".equals(e.getCode())) {\n        // maasId has no local UserLangChainInfo: verify template sync status / environment DB\n        // do not retry blindly — the row must exist first\n    }\n}","preventionTips":["Ensure the template synchronization job between MaaS/Xinghuu and Astron runs and alarms on failure.","Validate maasId against the local DB before presenting official templates in the UI.","Check templateSource routing so exported templates don't fall into the official-template branch.","Confirm you're pointed at the right environment's database (staging DBs lack prod templates).","Treat upstream template deletions as events that require unpublishing the Astron-side template too."],"tags":["template","maas","entity-not-found","workflow"],"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"}