iflytek/astron-agent · error · BusinessException

CREATE_BOT_FAILED

CREATE_BOT_FAILED

Error message

CREATE_BOT_FAILED

What it means

BusinessException with code CREATE_BOT_FAILED thrown by saveBotAndAddToList when either chatBotDataService.createBot or chatListDataService.insertChatBotList throws. The original exception is logged (with uid) and replaced by this generic business error, indicating the bot was not persisted.

Solutions

  1. Check the server logs for the 'Failed to save bot, uid: ...' entry to see the root-cause exception.
  2. Verify database connectivity and connection-pool health.
  3. Validate field lengths/nullability of the ChatBotForm fields against the table schema.
  4. Retry the create request once persistence is healthy; if it persists, report with the uid and stack trace from the log.

Example fix

// before: oversized fields sent straight to API
await createBot({ botName: name, description: veryLongText });
// after: clamp before calling
await createBot({ botName: name, description: veryLongText.slice(0, 500) });
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight: ensure required fields and lengths are valid
if (!form.botName?.trim() || form.description?.length > 500) throw new Error('Invalid bot fields');

Try / catch

try { await createBot(form); } catch (e) { if (e.code === 'CREATE_BOT_FAILED') { logServerSideHint(e); await sleep(500); return createBot(form); } throw e; }

Prevention

When it happens

Trigger: insertWorkflowBot, insertBotBasicInfo, copyBot, or upgradeCopyBot reaching the persistence step while the underlying DB insert into the bot base table or the bot list table fails — e.g. constraint violations, DB connectivity loss, or invalid/unmapped field data in ChatBotBase.

Common situations: Database outages or connection-pool exhaustion; schema drift where a new required column has no default; oversized field values (e.g. description/avatar exceeding column length); concurrent delete of the list record during copy.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/5557d7109b0ae5f6. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/commons/src/main/java/com/iflytek/astron/console/commons/service/bot/impl/BotServiceImpl.java:510

            URI uri = URI.create(mcpServerUrl);
            String scheme = uri.getScheme();
            // Use getAuthority() not getHost(): URI.getHost() returns null for hostnames containing
            // underscores (e.g. http://mcp_server:8080), common in internal Docker/K8s networks,
            // which would otherwise silently drop valid MCP server URLs.
            return StringUtils.isNotBlank(uri.getAuthority())
                    && ("http".equalsIgnoreCase(scheme) || "https".equalsIgnoreCase(scheme));
        } catch (IllegalArgumentException e) {
            return false;
        }
    }

    private void saveBotAndAddToList(ChatBotBase botBase) {
        try {
            chatBotDataService.createBot(botBase);
            chatListDataService.insertChatBotList(botBase);
        } catch (Exception e) {
            log.error("Failed to save bot, uid: {}", botBase.getUid(), e);
            throw new BusinessException(ResponseEnum.CREATE_BOT_FAILED);
        }
    }

    private BotInfoDto createBotInfoDto(Integer botId) {
        BotInfoDto dto = new BotInfoDto();
        dto.setBotId(botId);
        return dto;
    }

    private void updateWorkflowBotInternal(String uid, BotCreateForm bot, HttpServletRequest request, Long spaceId) {
        try {
            Integer botId = bot.getBotId();
            Integer botType = normalizeBotFormType(bot);
            ChatBotBase botBase = ChatBotBase.builder()
                    .uid(uid)
                    .id(botId)
                    .botType(botType)
                    .botName(bot.getName())

View on GitHub (pinned to 5e758547a8)