{"record":{"id":"0f327dd967c76bec","repo":"theonedev/onedev","slug":"target-branch-should-not-be-empty","errorCode":null,"errorMessage":"Target branch should not be empty","messagePattern":"Target branch should not be empty","errorType":"validation","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/step/CreatePullRequestStep.java","lineNumber":119,"sourceCode":"\t@SuppressWarnings(\"unused\")\n\tprivate static List<InputSuggestion> suggestVariables(String matchWith) {\n\t\treturn BuildSpec.suggestVariables(matchWith, true, true, false);\n\t}\n\n\t@SuppressWarnings(\"unused\")\n\tprivate static List<InputSuggestion> suggestRevisions(String matchWith) {\n\t\tProject project = Project.get();\n\t\tif (project != null)\n\t\t\treturn SuggestionUtils.suggestRevisions(project, matchWith);\n\t\telse\n\t\t\treturn new ArrayList<>();\n\t}\n\n\t@Override\n\tpublic ServerStepResult run(Long buildId, File inputDir, TaskLogger logger) {\n\t\treturn OneDev.getInstance(SessionService.class).call(() -> {\n\t\t\tif (StringUtils.isBlank(getTargetBranch())) \n\t\t\t\tthrow new ExplicitException(\"Target branch should not be empty\");\n\t\t\tif (StringUtils.isBlank(getSourceBranch())) \n\t\t\t\tthrow new ExplicitException(\"Source branch should not be empty\");\n\t\t\t\n\t\t\tvar build = OneDev.getInstance(BuildService.class).load(buildId);\n\t\t\t\n\t\t\tvar projectId = build.getProject().getId();\n\n\t\t\tProjectAndBranch target = new ProjectAndBranch(projectId, getTargetBranch());\n\t\t\tProjectAndBranch source = new ProjectAndBranch(projectId, getSourceBranch());\n\n\t\t\tif (target.equals(source)) {\n\t\t\t\tlogger.warning(\"Pull request will not be created as target branch is the same as source branch\");\n\t\t\t} else {\n\t\t\t\tvar pullRequestService = OneDev.getInstance(PullRequestService.class);\n\t\t\t\tvar pullRequest = pullRequestService.findOpen(target, source);\n\t\t\t\tif (pullRequest != null) {\n\t\t\t\t\tlogger.warning(\"A pull request has already been opened for specified branches\");\n\t\t\t\t} else {","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/step/CreatePullRequestStep.java#L101-L137","documentation":"CreatePullRequestStep.run validates that the resolved target branch is non-empty before opening a pull request; an empty value means the targetBranch setting (possibly variable-based) evaluated to nothing.","triggerScenarios":"Thrown at server-core/src/main/java/io/onedev/server/buildspec/step/CreatePullRequestStep.java:119 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set an explicit target branch in the step configuration.","Fix the variable/script that should supply the target branch name."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}