theonedev/onedev · error · ExplicitException

Name '${project.name}' is already used by another project un

Error message

Name '${project.name}' is already used by another project under '${parent.path}'

What it means

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.

Source

Thrown at server-core/src/main/java/io/onedev/server/rest/resource/ProjectResource.java:367

		auditService.audit(project, "changed project via RESTful API", oldAuditContent,
				VersionedXmlDoc.fromBean(ProjectData.from(project)).toXML());

		return Response.ok().build();
	}
	
	private void checkProjectCreationPermission(Subject subject, @Nullable Project parent) {
		if (parent != null && !SecurityUtils.canCreateChildren(subject, parent))
			throw new UnauthorizedException("Not authorized to create project under '" + parent.getPath() + "'");
		if (parent == null && !SecurityUtils.canCreateRootProjects(subject))
			throw new UnauthorizedException("Not authorized to create root project");
	}
	
	private void checkProjectNameDuplication(Project project) {
		Project parent = project.getParent();
		Project projectWithSameName = projectService.find(parent, project.getName());
		if (projectWithSameName != null && !projectWithSameName.equals(project)) {
			if (parent != null) {
				throw new ExplicitException("Name '" + project.getName() + "' is already used by another project under '"
						+ parent.getPath() + "'");
			} else {
				throw new ExplicitException("Name '" + project.getName() + "' is already used by another root project");
			}
		}
	}
	
	@Api(order=900, description="Update project settings")
	@Path("/{projectId}/setting")
    @POST
    public Response updateSetting(@PathParam("projectId") Long projectId, @NotNull ProjectSetting setting) {
		for (var boardSpec: setting.getIssueSetting().getBoardSpecs())
			boardSpec.populateEditColumns();
		var violations = validator.validate(setting);
		if (!violations.isEmpty()) {
			var violation = violations.iterator().next();
			throw new ExplicitException(violation.getPropertyPath() + ": " + violation.getMessage());
		}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Pick a different project name, or create the project under a different parent where the name is free.
  2. If the existing project is the one you intended to modify, use its id in the update call instead of creating a new one.
  3. Delete or rename the conflicting sibling project first, then retry.

Example fix

// before
POST /api/projects {"name": "app", "parentPath": "team-a"}  // 'team-a/app' already exists
// after
POST /api/projects {"name": "app-2", "parentPath": "team-a"}
// or update the existing project instead:
PUT /api/projects/{existingId} {"name": "app"}
Defensive patterns

Strategy: validation

Validate before calling

// Java: check sibling name availability before create/update
Project parent = project.getParent();
if (projectService.find(parent, project.getName()) != null) {
    throw new IllegalStateException("Project name '" + project.getName() + "' already used under " + (parent != null ? parent.getPath() : "root"));
}

Try / catch

try { projectService.create(...); } catch (ExplicitException e) { log.warn("Duplicate project name: {}", e.getMessage()); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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 theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/4fa29649ec667005. Report an issue: GitHub.