{"record":{"id":"98511d4a40a94bbd","repo":"theonedev/onedev","slug":"source-branch-should-not-be-empty","errorCode":null,"errorMessage":"Source branch should not be empty","messagePattern":"Source 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":121,"sourceCode":"\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 {\n\t\t\t\t\tpullRequest = new PullRequest();\n\t\t\t\t\tpullRequest.setTarget(target);","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/step/CreatePullRequestStep.java#L103-L139","documentation":"Guard in CreatePullRequestStep.run: the source branch property is blank after interpolation, so the pull request cannot be created from an unknown source; ExplicitException fails the step. Fix: define the source branch (check the property and any variables it uses).","triggerScenarios":"Thrown at server-core/src/main/java/io/onedev/server/buildspec/step/CreatePullRequestStep.java:121 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set an explicit source branch in the step configuration.","Ensure the variable/script supplying the source branch yields a value."],"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"}