{"record":{"id":"8f88ae1868e420ba","repo":"iflytek/astron-agent","slug":"bot-api-create-error","errorCode":"BOT_API_CREATE_ERROR","errorMessage":"BOT_API_CREATE_ERROR","messagePattern":"BOT_API_CREATE_ERROR","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/publish/impl/PublishApiServiceImpl.java","lineNumber":156,"sourceCode":"        if (Objects.isNull(botBase) || Objects.isNull(appMst)) {\n            throw new BusinessException(ResponseEnum.USER_APP_ID_NOT_EXISTE);\n        }\n\n        if (!redisUtil.tryLock(PUBLISH_API + uid, 3000, uuid)) {\n            throw new BusinessException(ResponseEnum.BOT_API_CREATE_LIMIT_ERROR);\n        }\n        try {\n            List<Integer> maasSupportedVersions = List.of(BotVersionEnum.WORKFLOW.getVersion());\n            if (maasSupportedVersions.contains(botBase.getVersion())) {\n                return createMaasApi(uid, appMst, botBase, spaceId, request);\n            } else {\n                throw new BusinessException(ResponseEnum.BOT_TYPE_NOT_SUPPORT);\n            }\n        } catch (BusinessException e) {\n            throw e;\n        } catch (Exception e) {\n            log.error(\"PublishApiServiceImpl.createBotApi : create Bot api error, request: {}\", createBotApiVo, e);\n            throw new BusinessException(ResponseEnum.BOT_API_CREATE_ERROR);\n        } finally {\n            redisUtil.unlock(PUBLISH_API + uid, uuid);\n        }\n\n    }\n\n    @Override\n    public BotApiInfoDTO getApiInfo(Long botId) {\n        String uid = RequestContextUtil.getUID();\n        ChatBotBase botBase = chatBotDataService.findOne(uid, botId);\n        if (Objects.isNull(botBase)) {\n            throw new BusinessException(ResponseEnum.BOT_NOT_EXISTS);\n        }\n        ChatBotApi botApi = chatBotApiService.getOneByUidAndBotId(uid, botId);\n        if (Objects.isNull(botApi)) {\n            return new BotApiInfoDTO();\n        }\n        AppMst appMst = appMstService.getByAppId(uid, botApi.getAppId());","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/publish/impl/PublishApiServiceImpl.java#L138-L174","documentation":"BOT_API_CREATE_ERROR is the catch-all thrown when any non-BusinessException escapes the createBotApi try block (after BOT_TYPE_NOT_SUPPORT dispatch). It wraps unexpected failures during MaaS API creation (createMaasApi) — network errors, tenant/model-service exceptions, NPEs — after logging the full request and stack trace. The Redis lock is still released in finally.","triggerScenarios":"createMaasApi throws a runtime exception: tenant/MaaS HTTP call fails, NPE on unexpected response shape, DB error inside the flow — anything not itself a BusinessException.","commonSituations":"MaaS endpoint misconfigured or down mid-deploy; auth credentials (apiKey/secret) invalid at tenant; timeout on outbound HTTP during API registration; regressions after upgrading dependent services.","solutions":["Read the logged 'create Bot api error' stack trace (log.error includes the full request) to find the root cause; the wrapper hides it.","Check health/connectivity of downstream MaaS/tenant services and retry once restored.","Validate the app's apiKey/apiSecret are present and valid before publishing.","Fix the underlying NPE/bug in createMaasApi if the trace points to code, then redeploy."],"exampleFix":"// before\ncatch (Exception e) {\n    throw new BusinessException(ResponseEnum.BOT_API_CREATE_ERROR); // root cause only in logs\n}\n// after\ncatch (Exception e) {\n    log.error(\"createBotApi failed: uid={}, botId={}, appId={}\", uid, vo.getBotId(), vo.getAppId(), e);\n    throw new BusinessException(ResponseEnum.BOT_API_CREATE_ERROR, e.getMessage()); // surface cause\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { publishApiService.createBotApi(vo, request, uid, spaceId); }\ncatch (BusinessException e) {\n    if (e.getCode() == ResponseEnum.BOT_API_CREATE_ERROR) { logAndRetryOrEscalate(e); } // root cause is in server log.error\n    else throw e;\n}","preventionTips":["Always check server logs for the wrapped root-cause stack trace before guessing.","Add health checks and timeouts on MaaS/tenant dependencies used by createMaasApi.","Validate app apiKey/apiSecret before publishing.","Wrap downstream calls in createMaasApi with specific error codes instead of relying on the catch-all."],"tags":["unexpected-exception","api-publish","maas"],"backgroundTag":"api-request-failed","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}