{"record":{"id":"483a4cae412c75d6","repo":"theonedev/onedev","slug":"target-already-up-to-date-with-source","errorCode":null,"errorMessage":"Target already up to date with source","messagePattern":"Target already up to date with source","errorType":"validation","errorClass":"NotAcceptableException","httpStatus":400,"severity":"info","filePath":"server-core/src/main/java/io/onedev/server/service/impl/DefaultPullRequestService.java","lineNumber":460,"sourceCode":"\t\texisting = findEffective(target, source);\n\t\tif (existing != null) {\n\t\t\tif (existing.isOpen())\n\t\t\t\tthrow new NotAcceptableException(\"Another pull request already opened for this change\");\n\t\t\telse\n\t\t\t\tthrow new NotAcceptableException(\"Another pull request already merged the change\");\n\t\t}\n\n\t\tif (request.getBaseCommitHash() == null) {\n\t\t\tObjectId baseCommitId = gitService.getMergeBase(\n\t\t\t\t\ttarget.getProject(), target.getObjectId(),\n\t\t\t\t\tsource.getProject(), source.getObjectId());\n\t\t\tif (baseCommitId == null)\n\t\t\t\tthrow new NotAcceptableException(\"No common base for target and source\");\n\t\t\trequest.setBaseCommitHash(baseCommitId.name());\n\t\t}\n\n\t\tif (request.getBaseCommitHash().equals(source.getObjectName()))\n\t\t\tthrow new NotAcceptableException(\"Target already up to date with source\");\n\n\t\tif (request.getUpdates().isEmpty()) {\n\t\t\tPullRequestUpdate update = new PullRequestUpdate();\n\t\t\trequest.getUpdates().add(update);\n\t\t\trequest.setUpdates(request.getUpdates());\n\t\t\tupdate.setRequest(request);\n\t\t\tupdate.setHeadCommitHash(source.getObjectName());\n\t\t\tupdate.setTargetHeadCommitHash(target.getObjectName());\n\t\t}\n\n\t\tif (request.getAssignments().isEmpty()) {\n\t\t\tfor (var assignee: target.getProject().findDefaultPullRequestAssignees()) {\n\t\t\t\tPullRequestAssignment assignment = new PullRequestAssignment();\n\t\t\t\tassignment.setRequest(request);\n\t\t\t\tassignment.setUser(assignee);\n\t\t\t\trequest.getAssignments().add(assignment);\n\t\t\t}\n\t\t}","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/service/impl/DefaultPullRequestService.java#L442-L478","documentation":"DefaultPullRequestService.open() rejects the request when the computed base commit equals the source branch's current head (getObjectName()), meaning the target already contains everything on source — there is nothing to merge, so a PR would be empty.","triggerScenarios":"Calling open() when request.getBaseCommitHash().equals(source.getObjectName()): target is already at or ahead of the source head, i.e. zero diff between merge base and source tip.","commonSituations":"Opening a PR from a branch that was already fast-forward-merged; target branch was reset to the source head; automation opening PRs after a merge bot already fast-forwarded; comparing a branch with itself after rebase onto target.","solutions":["Verify there are unmerged commits: the source head must differ from the target tip; push new commits first","Pull/rebase source on top of target to add new work, then open the PR","If the work is already merged, skip PR creation and close the task","Check your automation isn't opening PRs against the wrong (already-synced) target branch"],"exampleFix":"// before\nif (target.getObjectId().equals(source.getObjectId())) skip; // wrong check\npullRequestService.open(request);\n// after\nif (request.getBaseCommitHash().equals(source.getObjectName())) {\n    logger.info(\"No changes from {} to {}\", source, target);\n    return;\n}\npullRequestService.open(request);","handlingStrategy":"validation","validationCode":"if (request.getBaseCommitHash().equals(source.getObjectName()))\n    return; // target already up to date, nothing to merge","typeGuard":null,"tryCatchPattern":"try {\n    pullRequestService.open(request);\n} catch (NotAcceptableException e) {\n    if (e.getMessage().contains(\"Target already up to date\"))\n        logger.info(\"Nothing to merge; skipping PR creation\");\n    else throw e;\n}","preventionTips":["Compute the merge base and compare with the source head before opening","Check branch diff emptiness in CI before creating PRs","After merges, fast-forward/delete the source branch"],"tags":["pull-request","no-changes","empty-diff","onedev"],"backgroundTag":"invalid-state-transition","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"}