iflytek/astron-agent · error · BusinessException
CREATE_BOT_FAILED
CREATE_BOT_FAILED
Error message
CREATE_BOT_FAILED
What it means
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.
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
Example fix
// before (insertWorkflowBot swallows the cause)
BotInfoDto botInfoDto = botService.insertWorkflowBot(uid, maasDuplicate, spaceId, BotVersionEnum.WORKFLOW.getVersion());
if (botInfoDto == null) { throw new BusinessException(ResponseEnum.CREATE_BOT_FAILED); }
// after (log the cause before throwing)
BotInfoDto botInfoDto = botService.insertWorkflowBot(uid, maasDuplicate, spaceId, BotVersionEnum.WORKFLOW.getVersion());
if (botInfoDto == null) {
log.error("insertWorkflowBot returned null, uid={}, maasId={}, spaceId={}", uid, maasDuplicate.getMaasId(), spaceId);
throw new BusinessException(ResponseEnum.CREATE_BOT_FAILED);
} Defensive patterns
Strategy: try-catch
Validate before calling
if (spaceId == null || spaceId <= 0) { throw new IllegalArgumentException("valid spaceId required"); } Type guard
BotInfoDto bot = botService.insertWorkflowBot(...);
if (bot == null || bot.getBotId() == null) { /* handle creation failure */ } Try / catch
try {
botMaasService.createFromTemplate(uid, req, httpRequest);
} catch (BusinessException e) {
if (ResponseEnum.CREATE_BOT_FAILED.getCode().equals(e.getCode())) {
// surface 'bot creation failed, please retry' and check bot service/DB health
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/0b57403e3cb0fa48.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/BotMaasServiceImpl.java:114
return createFromExportedTemplate(uid, maasDuplicate, request);
}
return createFromOfficialTemplate(uid, maasDuplicate, request);
}
private BotInfoDto createFromOfficialTemplate(String uid, MaasDuplicate maasDuplicate, HttpServletRequest request) {
Long spaceId = SpaceInfoUtil.getSpaceId();
// Create an event, consumed by /maasCopySynchronize
Long maasId = maasDuplicate.getMaasId();
UserLangChainInfo userLangChainInfo = userLangChainDataService.selectByMaasId(maasId);
if (Objects.isNull(userLangChainInfo)) {
log.info("----- Xinghuo did not find Astron workflow: {}", JSONObject.toJSONString(userLangChainInfo));
throw new BusinessException(ResponseEnum.BOT_NOT_EXIST);
}
redissonClient.getBucket(MaasUtil.generatePrefix(uid, Math.toIntExact(userLangChainInfo.getId()))).set(userLangChainInfo.getId().toString(), Duration.ofSeconds(60));
BotInfoDto botInfoDto = botService.insertWorkflowBot(uid, maasDuplicate, spaceId, BotVersionEnum.WORKFLOW.getVersion());
// Check if response is successful
if (botInfoDto == null) {
throw new BusinessException(ResponseEnum.CREATE_BOT_FAILED);
}
// Copy a new workflow for the assistant
JSONObject res = maasUtil.copyWorkFlow(maasDuplicate.getMaasId(), request, BotVersionEnum.WORKFLOW.getVersion(), Long.valueOf(botInfoDto.getBotId()), null);
if (Objects.isNull(res) || res.isEmpty()) {
throw new BusinessException(ResponseEnum.CREATE_BOT_FAILED);
}
Integer botId = botInfoDto.getBotId();
botService.addMaasInfo(uid, res, botId, spaceId);
botInfoDto.setFlowId(res.getJSONObject("data").getLong("id"));
return botInfoDto;
}
private BotInfoDto createFromExportedTemplate(String uid, MaasDuplicate maasDuplicate, HttpServletRequest request) {
Long templateId = maasDuplicate.getTemplateId();
if (templateId == null) {
throw new BusinessException(ResponseEnum.PARAMETER_ERROR);
}
View on GitHub (pinned to 5e758547a8)