theonedev/onedev · error · NotAcceptableException

Branch "{0}" already exists

Error message

Branch "{0}" already exists

What it means

ensureBranch builds a suggested branch name from the issue number and title; if a branch with that name already exists in the project (NotAcceptableException via MessageFormat), the issue cannot get its own ensure-branch under that name.

Source

Thrown at server-core/src/main/java/io/onedev/server/service/impl/DefaultIssueService.java:1483

		} else {
			return prefixWithSlash + "issue-" + issue.getNumber();
		}
	}

	@Sessional
	@Override
	public String ensureBranch(Subject subject, Issue issue) {
		if (issue.getBranch() != null)
			return issue.getBranch();

		Project project = issue.getProject();
		String suggestedBranch = suggestBranch(issue);

		if (!SecurityUtils.canCreateBranch(project, suggestedBranch))
			throw new UnauthorizedException("No permission to create branch: " + suggestedBranch);

		if (project.getBranchRef(suggestedBranch) != null) {
			throw new NotAcceptableException(MessageFormat.format("Branch \"{0}\" already exists", suggestedBranch));
		} else {
			RevCommit commit = null;
			if (issue.getFieldCommitId() != null)
				commit = project.getRevCommit(issue.getFieldCommitId(), false);
			if (commit == null) {
				String defaultBranch = project.getDefaultBranch();
				if (defaultBranch == null) 
					throw new NotAcceptableException("Default branch is not available");
				else 
					commit = project.getRevCommit(defaultBranch, true);	
			}		
			if (!project.isCommitSignatureRequirementSatisfied(SecurityUtils.getUser(subject), suggestedBranch, commit)) {
				throw new NotAcceptableException("Valid signature required for head commit of this branch per branch protection rule");
			} else {
				gitService.createBranch(project, suggestedBranch, commit.name());
				return suggestedBranch;
			}
		}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Point the issue at the existing branch or use a differently named branch.
  2. Resolve the collision by choosing a unique branch suffix.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server-core/src/main/java/io/onedev/server/service/impl/DefaultIssueService.java:1483 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/38a3bb86bd867218. Report an issue: GitHub.