{"record":{"id":"5557d7109b0ae5f6","repo":"iflytek/astron-agent","slug":"create-bot-failed","errorCode":"CREATE_BOT_FAILED","errorMessage":"CREATE_BOT_FAILED","messagePattern":"CREATE_BOT_FAILED","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/commons/src/main/java/com/iflytek/astron/console/commons/service/bot/impl/BotServiceImpl.java","lineNumber":510,"sourceCode":"            URI uri = URI.create(mcpServerUrl);\n            String scheme = uri.getScheme();\n            // Use getAuthority() not getHost(): URI.getHost() returns null for hostnames containing\n            // underscores (e.g. http://mcp_server:8080), common in internal Docker/K8s networks,\n            // which would otherwise silently drop valid MCP server URLs.\n            return StringUtils.isNotBlank(uri.getAuthority())\n                    && (\"http\".equalsIgnoreCase(scheme) || \"https\".equalsIgnoreCase(scheme));\n        } catch (IllegalArgumentException e) {\n            return false;\n        }\n    }\n\n    private void saveBotAndAddToList(ChatBotBase botBase) {\n        try {\n            chatBotDataService.createBot(botBase);\n            chatListDataService.insertChatBotList(botBase);\n        } catch (Exception e) {\n            log.error(\"Failed to save bot, uid: {}\", botBase.getUid(), e);\n            throw new BusinessException(ResponseEnum.CREATE_BOT_FAILED);\n        }\n    }\n\n    private BotInfoDto createBotInfoDto(Integer botId) {\n        BotInfoDto dto = new BotInfoDto();\n        dto.setBotId(botId);\n        return dto;\n    }\n\n    private void updateWorkflowBotInternal(String uid, BotCreateForm bot, HttpServletRequest request, Long spaceId) {\n        try {\n            Integer botId = bot.getBotId();\n            Integer botType = normalizeBotFormType(bot);\n            ChatBotBase botBase = ChatBotBase.builder()\n                    .uid(uid)\n                    .id(botId)\n                    .botType(botType)\n                    .botName(bot.getName())","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/commons/src/main/java/com/iflytek/astron/console/commons/service/bot/impl/BotServiceImpl.java#L492-L528","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the server logs for the 'Failed to save bot, uid: ...' entry to see the root-cause exception.","Verify database connectivity and connection-pool health.","Validate field lengths/nullability of the ChatBotForm fields against the table schema.","Retry the create request once persistence is healthy; if it persists, report with the uid and stack trace from the log."],"exampleFix":"// before: oversized fields sent straight to API\nawait createBot({ botName: name, description: veryLongText });\n// after: clamp before calling\nawait createBot({ botName: name, description: veryLongText.slice(0, 500) });","handlingStrategy":"try-catch","validationCode":"// pre-flight: ensure required fields and lengths are valid\nif (!form.botName?.trim() || form.description?.length > 500) throw new Error('Invalid bot fields');","typeGuard":null,"tryCatchPattern":"try { await createBot(form); } catch (e) { if (e.code === 'CREATE_BOT_FAILED') { logServerSideHint(e); await sleep(500); return createBot(form); } throw e; }","preventionTips":["Validate field lengths against schema before calling","Retry once on transient failures; surface root cause from server logs on repeat","Monitor DB health to distinguish infra vs data issues","Never silently swallow the underlying exception server-side when debugging"],"tags":["database","persistence","java","spring-boot"],"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"}