theonedev/onedev · error · NotAcceptableException
Source and target are the same
Error message
Source and target are the same
What it means
open throws this NotAcceptableException when the pull request's source and target BranchInfo are equal — a PR from a branch to itself makes no sense, so OneDev rejects it up front in open(). The comparison is target.equals(source).
Source
Thrown at server-core/src/main/java/io/onedev/server/service/impl/DefaultPullRequestService.java:436
}
projectService.deleteBranch(request.getSourceProject(), request.getSourceBranch());
}
}
@Transactional
@Override
public void open(PullRequest request) {
Preconditions.checkArgument(request.isNew());
var target = Preconditions.checkNotNull(request.getTarget(),
"Pull request target must be set before calling open");
var source = Preconditions.checkNotNull(request.getSource(),
"Pull request source must be set before calling open");
Preconditions.checkNotNull(request.getSubmitter(),
"Pull request submitter must be set before calling open");
if (target.equals(source))
throw new NotAcceptableException("Source and target are the same");
PullRequest existing = findOpen(target, source);
if (existing != null)
throw new NotAcceptableException("Another pull request already opened for this change");
existing = findEffective(target, source);
if (existing != null) {
if (existing.isOpen())
throw new NotAcceptableException("Another pull request already opened for this change");
else
throw new NotAcceptableException("Another pull request already merged the change");
}
if (request.getBaseCommitHash() == null) {
ObjectId baseCommitId = gitService.getMergeBase(
target.getProject(), target.getObjectId(),
source.getProject(), source.getObjectId());
if (baseCommitId == null)View on GitHub (pinned to d44925c47c)
Solutions
- Set the target branch to the branch you intend to merge INTO (usually the default/main branch), keeping source as the feature branch
- Verify source and target differ (project + branch name) before calling open
- Fix form/script defaults so target is not pre-filled with the source branch
Example fix
// before request.setSource(new BranchInfo(project.getId(), branch)); request.setTarget(new BranchInfo(project.getId(), branch)); // same -> error // after request.setSource(new BranchInfo(project.getId(), featureBranch)); request.setTarget(new BranchInfo(project.getId(), "main"));
Defensive patterns
Strategy: validation
Validate before calling
if (request.getTarget().equals(request.getSource()))
throw new IllegalArgumentException("source and target must differ"); Type guard
boolean distinctBranches(PullRequest r) {
return r.getSource() != null && r.getTarget() != null && !r.getSource().equals(r.getTarget());
} Try / catch
try {
prService.open(request);
} catch (NotAcceptableException e) {
// source == target; fix branch selection
} Prevention
- Default the target to the main/default branch in create-PR forms
- Compare source and target (project + branch) before submission
- Guard automation variables so target cannot equal source
When it happens
Trigger: Calling DefaultPullRequestService.open(request) (or the REST/UI create-PR flow) where request.getSource() equals request.getTarget() — same project, same branch name — e.g. pre-filling the form with the same branch on both sides.
Common situations: Automation or UI defaults selecting the current branch for both source and target; scripting PR creation from a variable that happens to equal the target branch; creating a PR from a repo's default branch to itself.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Reviewer not found:
- Pull request submitter cannot be reviewer
- Assignee not found:
- No permission to read code of source project:
- No permission to read code of target project:
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/90e8412075a7a41b.
Report an issue: GitHub.