{"record":{"id":"20b90b730ee81b5c","repo":"iflytek/astron-agent","slug":"user-app-name-repeat","errorCode":"USER_APP_NAME_REPEAT","errorMessage":"USER_APP_NAME_REPEAT","messagePattern":"USER_APP_NAME_REPEAT","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"warning","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/publish/impl/PublishApiServiceImpl.java","lineNumber":92,"sourceCode":"    @Autowired\n    private UserLangChainDataService userLangChainDataService;\n\n    @Autowired\n    private MaasUtil maasUtil;\n\n    @Autowired\n    private ReleaseManageClientService releaseManageClientService;\n\n    private static final String PUBLISH_API = \"publish_api\";\n\n    private static final String BOT_API_MAAS_URL = \"/workflow/v1/chat/completions\";\n\n    @Override\n    public Boolean createApp(CreateAppVo createAppVo) {\n        String uid = RequestContextUtil.getUID();\n\n        if (appMstService.exist(createAppVo.getAppName())) {\n            throw new BusinessException(ResponseEnum.USER_APP_NAME_REPEAT);\n        }\n\n        String appId = tenantService.createApp(uid, createAppVo.getAppName(), createAppVo.getAppDescribe());\n        if (StringUtils.isBlank(appId)) {\n            throw new BusinessException(ResponseEnum.USER_APP_ID_CREATE_ERROR);\n        }\n        TenantAuth tenantAuth = tenantService.getAppDetail(appId);\n        if (Objects.isNull(tenantAuth)) {\n            throw new BusinessException(ResponseEnum.USER_APP_ID_CREATE_ERROR);\n        }\n        appMstService.insert(uid, appId, createAppVo.getAppName(), createAppVo.getAppDescribe(), tenantAuth.getApiKey(), tenantAuth.getApiSecret());\n\n        return true;\n    }\n\n    @Override\n    public List<AppListDTO> getAppList() {\n        String uid = RequestContextUtil.getUID();","sourceCodeStart":74,"sourceCodeEnd":110,"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#L74-L110","documentation":"USER_APP_NAME_REPEAT is thrown by createApp when appMstService.exist() finds an existing app with the same app name for the user. App names must be unique, so duplicate-name creation is rejected before the tenant service is called.","triggerScenarios":"Calling the create-app API with an appName that already exists in app_mst; retrying a create that actually succeeded earlier (client didn't see the response).","commonSituations":"User re-submits a form after a timeout; automation scripts create apps in a loop without unique names; copy-pasting an existing app's name.","solutions":["Choose a different, unique app name and retry.","Check existing apps first (list apps / appMstService.exist) and reuse the existing app instead of creating a new one.","If the name was left over from a failed previous creation, delete the stale app then recreate.","Make automated naming unique (suffix with timestamp/UUID)."],"exampleFix":"// before\npublishApiService.createApp(new CreateAppVo(\"my-app\", \"desc\")); // may throw if name taken\n// after\nString name = \"my-app\";\nif (appMstService.exist(name)) {\n    name = name + \"-\" + System.currentTimeMillis();\n}\npublishApiService.createApp(new CreateAppVo(name, \"desc\"));","handlingStrategy":"validation","validationCode":"if (appMstService.exist(appName)) { throw new BusinessException(ResponseEnum.USER_APP_NAME_REPEAT); }","typeGuard":null,"tryCatchPattern":"try { publishApiService.createApp(vo); }\ncatch (BusinessException e) { if (e.getCode() == ResponseEnum.USER_APP_NAME_REPEAT) { showNameTakenMessage(); } else throw e; }","preventionTips":["Check name availability asynchronously as the user types.","Use unique suffixes in automated/CI app creation.","Reuse existing apps instead of recreating with the same name."],"tags":["duplicate","validation","app-creation"],"backgroundTag":"file-already-exists","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"}