apache/dolphinscheduler · error

PROJECT_ALREADY_EXISTS

PROJECT_ALREADY_EXISTS

Error message

Project {} already exists.

What it means

createProject returns PROJECT_ALREADY_EXISTS when projectDao.queryByName finds an existing project with the same name for the user. Project names must be unique, so duplicate creation is rejected with this message.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java:114

     * @return returns an error if it exists
     */
    @Override
    @Transactional
    public Result createProject(User loginUser, String name, String desc) {
        Result result = new Result();

        checkDesc(result, desc);
        if (result.getCode() != Status.SUCCESS.getCode()) {
            return result;
        }
        if (!canOperatorPermissions(loginUser, null, AuthorizationType.PROJECTS, PROJECT_CREATE)) {
            putMsg(result, Status.USER_NO_OPERATION_PERM);
            return result;
        }

        Project project = projectDao.queryByName(name);
        if (project != null) {
            log.warn("Project {} already exists.", project.getName());
            putMsg(result, Status.PROJECT_ALREADY_EXISTS, name);
            return result;
        }

        Date now = new Date();

        project = Project
                .builder()
                .name(name)
                .code(CodeGenerateUtils.genCode())
                .description(desc)
                .userId(loginUser.getId())
                .userName(loginUser.getUserName())
                .createTime(now)
                .updateTime(now)
                .build();

        if (projectDao.insert(project) > 0) {

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Check the project list first and reuse the existing project instead of creating a new one.
  2. Choose a unique project name (add a team/env suffix, e.g. 'reports-prod').
  3. Make creation scripts idempotent: query by name before POSTing, and treat PROJECT_ALREADY_EXISTS as success.

Example fix

// before
projectService.createProject(user, "my-project", "desc"); // fails on rerun
// after
if (projectDao.queryByName("my-project") == null) {
    projectService.createProject(user, "my-project", "desc");
}
Defensive patterns

Strategy: validation

Validate before calling

Project existing = projectDao.queryByName(name);
if (existing != null) { /* reuse existing.getCode() */ }

Try / catch

catch (ServiceException e) { if (e.getCode() == Status.PROJECT_ALREADY_EXISTS) { /* idempotent success path */ } }

Prevention

When it happens

Trigger: POST /projects with a 'name' that already exists (project names are unique across the instance), after the create-permission check passes.

Common situations: Double-clicking the create button; CI bootstrap script re-run that recreates projects; renaming/merging environments where project names overlap; multi-user setups where another user already claimed the name.

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 apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/836c5590961a931a. Report an issue: GitHub.