{"record":{"id":"4cf2d09fb056c73a","repo":"theonedev/onedev","slug":"name-project-name-is-already-used-by-another-4cf2d0","errorCode":null,"errorMessage":"Name '${project.name}' is already used by another root project","messagePattern":"Name '(.+?)' is already used by another root project","errorType":"http","errorClass":"ExplicitException","httpStatus":500,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/rest/resource/ProjectResource.java","lineNumber":370,"sourceCode":"\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}\n\n    \tProject project = projectService.load(projectId);\n    \tif (!SecurityUtils.canManageProject(project)) ","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/rest/resource/ProjectResource.java#L352-L388","documentation":"Variant of the duplicate-name check for root-level projects: when a project has no parent, its name must be unique among all root projects. checkProjectNameDuplication throws ExplicitException when another root project already uses the name.","triggerScenarios":"Creating or renaming a project with no parent (parent == null) via the REST API when a root project with the same name already exists.","commonSituations":"CI/automation creating top-level projects with generic names like 'build' or 'test' that already exist; importing projects that were previously nested but are now created at root level.","solutions":["Use a unique root-level project name (or nest it under a parent where the name is available).","Rename or remove the conflicting existing root project.","If the goal is to modify the existing root project, issue an update against its projectId instead."],"exampleFix":"// before\nPOST /api/projects {\"name\": \"infra\"}  // root project 'infra' already exists\n// after\nPOST /api/projects {\"name\": \"infra\", \"parentPath\": \"platform\"}\n// or unique name\nPOST /api/projects {\"name\": \"infra-prod\"}","handlingStrategy":"validation","validationCode":"// Ensure root-level name uniqueness before create\nif (project.getParent() == null && projectService.find(null, project.getName()) != null) {\n    throw new IllegalStateException(\"Root project '\" + project.getName() + \"' already exists\");\n}","typeGuard":null,"tryCatchPattern":"try { projectService.create(...); } catch (ExplicitException e) { log.warn(\"Duplicate root project name: {}\", e.getMessage()); }","preventionTips":["Namespace automation-created projects under a parent folder","Maintain a naming convention for root projects","List existing root projects before creating new ones"],"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-14T00:17:10.932Z"}