{"record":{"id":"4fa29649ec667005","repo":"theonedev/onedev","slug":"name-project-name-is-already-used-by-another","errorCode":null,"errorMessage":"Name '${project.name}' is already used by another project under '${parent.path}'","messagePattern":"Name '(.+?)' is already used by another project under '(.+?)'","errorType":"http","errorClass":"ExplicitException","httpStatus":500,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/rest/resource/ProjectResource.java","lineNumber":367,"sourceCode":"\t\tauditService.audit(project, \"changed project via RESTful API\", oldAuditContent,\n\t\t\t\tVersionedXmlDoc.fromBean(ProjectData.from(project)).toXML());\n\n\t\treturn Response.ok().build();\n\t}\n\t\n\tprivate void checkProjectCreationPermission(Subject subject, @Nullable Project parent) {\n\t\tif (parent != null && !SecurityUtils.canCreateChildren(subject, parent))\n\t\t\tthrow new UnauthorizedException(\"Not authorized to create project under '\" + parent.getPath() + \"'\");\n\t\tif (parent == null && !SecurityUtils.canCreateRootProjects(subject))\n\t\t\tthrow new UnauthorizedException(\"Not authorized to create root project\");\n\t}\n\t\n\tprivate void checkProjectNameDuplication(Project project) {\n\t\tProject parent = project.getParent();\n\t\tProject projectWithSameName = projectService.find(parent, project.getName());\n\t\tif (projectWithSameName != null && !projectWithSameName.equals(project)) {\n\t\t\tif (parent != null) {\n\t\t\t\tthrow new ExplicitException(\"Name '\" + project.getName() + \"' is already used by another project under '\"\n\t\t\t\t\t\t+ parent.getPath() + \"'\");\n\t\t\t} else {\n\t\t\t\tthrow new ExplicitException(\"Name '\" + project.getName() + \"' is already used by another root project\");\n\t\t\t}\n\t\t}\n\t}\n\t\n\t@Api(order=900, description=\"Update project settings\")\n\t@Path(\"/{projectId}/setting\")\n    @POST\n    public Response updateSetting(@PathParam(\"projectId\") Long projectId, @NotNull ProjectSetting setting) {\n\t\tfor (var boardSpec: setting.getIssueSetting().getBoardSpecs())\n\t\t\tboardSpec.populateEditColumns();\n\t\tvar violations = validator.validate(setting);\n\t\tif (!violations.isEmpty()) {\n\t\t\tvar violation = violations.iterator().next();\n\t\t\tthrow new ExplicitException(violation.getPropertyPath() + \": \" + violation.getMessage());\n\t\t}","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/rest/resource/ProjectResource.java#L349-L385","documentation":"OneDev enforces unique project names among sibling projects under the same parent (and among root projects). In the REST API, ProjectResource.checkProjectNameDuplication throws ExplicitException when projectService.find(parent, name) finds a different project with the same name under the same parent. This is a user-facing explicit error, not a bug.","triggerScenarios":"POST/PUT to the REST project endpoints (createProject, updateProject) with a project whose name already exists under the same parent path; also updating a project to a name taken by a sibling.","commonSituations":"Automated provisioning scripts creating projects in bulk that collide with an existing sibling; renaming a project to a name already used by a brother project; restoring/migrating projects into a parent that already contains a project of that name.","solutions":["Pick a different project name, or create the project under a different parent where the name is free.","If the existing project is the one you intended to modify, use its id in the update call instead of creating a new one.","Delete or rename the conflicting sibling project first, then retry."],"exampleFix":"// before\nPOST /api/projects {\"name\": \"app\", \"parentPath\": \"team-a\"}  // 'team-a/app' already exists\n// after\nPOST /api/projects {\"name\": \"app-2\", \"parentPath\": \"team-a\"}\n// or update the existing project instead:\nPUT /api/projects/{existingId} {\"name\": \"app\"}","handlingStrategy":"validation","validationCode":"// Java: check sibling name availability before create/update\nProject parent = project.getParent();\nif (projectService.find(parent, project.getName()) != null) {\n    throw new IllegalStateException(\"Project name '\" + project.getName() + \"' already used under \" + (parent != null ? parent.getPath() : \"root\"));\n}","typeGuard":null,"tryCatchPattern":"try { projectService.create(...); } catch (ExplicitException e) { log.warn(\"Duplicate project name: {}\", e.getMessage()); }","preventionTips":["Generate project names with unique suffixes in automation","Check for an existing project under the same parent before creating","Prefer updating existing projects over creating duplicates"],"tags":["rest-api","naming-conflict","project-management"],"backgroundTag":"file-already-exists","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}