{"record":{"id":"836c5590961a931a","repo":"apache/dolphinscheduler","slug":"project-already-exists","errorCode":"PROJECT_ALREADY_EXISTS","errorMessage":"Project {} already exists.","messagePattern":"Project (.+?) already exists\\.","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java","lineNumber":114,"sourceCode":"     * @return returns an error if it exists\n     */\n    @Override\n    @Transactional\n    public Result createProject(User loginUser, String name, String desc) {\n        Result result = new Result();\n\n        checkDesc(result, desc);\n        if (result.getCode() != Status.SUCCESS.getCode()) {\n            return result;\n        }\n        if (!canOperatorPermissions(loginUser, null, AuthorizationType.PROJECTS, PROJECT_CREATE)) {\n            putMsg(result, Status.USER_NO_OPERATION_PERM);\n            return result;\n        }\n\n        Project project = projectDao.queryByName(name);\n        if (project != null) {\n            log.warn(\"Project {} already exists.\", project.getName());\n            putMsg(result, Status.PROJECT_ALREADY_EXISTS, name);\n            return result;\n        }\n\n        Date now = new Date();\n\n        project = Project\n                .builder()\n                .name(name)\n                .code(CodeGenerateUtils.genCode())\n                .description(desc)\n                .userId(loginUser.getId())\n                .userName(loginUser.getUserName())\n                .createTime(now)\n                .updateTime(now)\n                .build();\n\n        if (projectDao.insert(project) > 0) {","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java#L96-L132","documentation":"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.","triggerScenarios":"POST /projects with a 'name' that already exists (project names are unique across the instance), after the create-permission check passes.","commonSituations":"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.","solutions":["Check the project list first and reuse the existing project instead of creating a new one.","Choose a unique project name (add a team/env suffix, e.g. 'reports-prod').","Make creation scripts idempotent: query by name before POSTing, and treat PROJECT_ALREADY_EXISTS as success."],"exampleFix":"// before\nprojectService.createProject(user, \"my-project\", \"desc\"); // fails on rerun\n// after\nif (projectDao.queryByName(\"my-project\") == null) {\n    projectService.createProject(user, \"my-project\", \"desc\");\n}","handlingStrategy":"validation","validationCode":"Project existing = projectDao.queryByName(name);\nif (existing != null) { /* reuse existing.getCode() */ }","typeGuard":null,"tryCatchPattern":"catch (ServiceException e) { if (e.getCode() == Status.PROJECT_ALREADY_EXISTS) { /* idempotent success path */ } }","preventionTips":["Make bootstrap scripts idempotent: query before create.","Use environment-suffixed project names to reduce collisions.","Disable duplicate submit in the create-project form."],"tags":["project","duplicate","uniqueness"],"backgroundTag":"file-already-exists","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}