alibaba/spring-ai-alibaba · error · BizException
AppNameExists
AppNameExists
Error message
App name already exists.
What it means
BizException with code AppNameExists thrown by AppServiceImpl.createApp when an app with the same name already exists in the caller's workspace (getAppByName returns non-null). The library enforces workspace-unique app names, so creation is rejected before insert.
Source
Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/AppServiceImpl.java:101
this.redisManager = redisManager;
this.referService = referService;
}
/**
* Creates a new application with initial version
* @param application Application details to create
* @return ID of the created application
*/
@Override
@Transactional(rollbackFor = Exception.class)
public String createApp(Application application) {
try {
RequestContext context = RequestContextHolder.getRequestContext();
// check if app name exists
AppEntity entity = getAppByName(context.getWorkspaceId(), application.getName());
if (entity != null) {
throw new BizException(ErrorCode.APP_NAME_EXISTS.toError());
}
String appId = IdGenerator.idStr();
// insert application
entity = BeanCopierUtils.copy(application, AppEntity.class);
entity.setAppId(appId);
entity.setStatus(AppStatus.DRAFT);
entity.setWorkspaceId(context.getWorkspaceId());
entity.setGmtCreate(new Date());
entity.setGmtModified(new Date());
entity.setCreator(context.getAccountId());
entity.setModifier(context.getAccountId());
this.save(entity);
// insert application version
AppVersionEntity versionEntity = new AppVersionEntity();
versionEntity.setAppId(appId);
versionEntity.setWorkspaceId(context.getWorkspaceId());View on GitHub (pinned to f82da0b50f)
Solutions
- Check name availability first via getAppByName (or a list call) and use a unique name.
- Make creation idempotent: if the app already exists, fetch it instead of creating.
- Append a unique suffix (workspace/user/timestamp) when auto-generating names.
Example fix
// before
appService.createApp(application); // may throw AppNameExists
// after
if (appService.getAppByName(workspaceId, application.getName()) == null) {
appService.createApp(application);
} else {
application.setName(application.getName() + "-" + System.currentTimeMillis());
appService.createApp(application);
} Defensive patterns
Strategy: validation
Validate before calling
if (appService.getAppByName(workspaceId, application.getName()) != null) {
application.setName(application.getName() + "-" + UUID.randomUUID().toString().substring(0, 8));
} Try / catch
try { appService.createApp(application); } catch (BizException e) { if ("AppNameExists".equals(e.getCode())) { /* fetch existing or rename */ } else throw e; } Prevention
- Make create scripts idempotent: check existence before create.
- Generate names with unique suffixes in automation.
- Handle concurrent creates with a retry-and-fetch strategy.
When it happens
Trigger: Calling createApp(application) whose name duplicates an existing app in the same workspace; retrying a create that partially succeeded; seeding scripts run twice.
Common situations: Bootstrap/config-as-code re-runs creating apps idempotently; two users creating the same app name concurrently; copying examples without renaming the app.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/cb1fea95d055638f.
Report an issue: GitHub.