{"record":{"id":"a78e0b2442c8c82e","repo":"theonedev/onedev","slug":"branch-name-should-not-be-empty","errorCode":null,"errorMessage":"Branch name should not be empty","messagePattern":"Branch name should not be empty","errorType":"validation","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/step/CreateBranchStep.java","lineNumber":103,"sourceCode":"\tpublic void setAccessTokenSecret(String accessTokenSecret) {\n\t\tthis.accessTokenSecret = accessTokenSecret;\n\t}\n\n\t@SuppressWarnings(\"unused\")\n\tprivate static List<String> getAccessTokenSecretChoices() {\n\t\treturn Project.get().getHierarchyJobSecrets()\n\t\t\t\t.stream().map(it->it.getName()).collect(Collectors.toList());\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\tvar build = OneDev.getInstance(BuildService.class).load(buildId);\n\t\t\tProject project = build.getProject();\n\t\t\tString branchName = branchNameProvider.getBranchName(build);\n\n\t\t\tif (StringUtils.isBlank(branchName))\n\t\t\t\tthrow new ExplicitException(\"Branch name should not be empty\");\n\t\t\tif (!Repository.isValidRefName(GitUtils.branch2ref(branchName)))\n\t\t\t\tthrow new ExplicitException(\"Invalid branch name: \" + branchName);\n\n\t\t\tif (build.canCreateBranch(getAccessTokenSecret(), branchName)) {\n\t\t\t\tRefFacade branchRef = project.getBranchRef(branchName);\n\t\t\t\tif (branchRef != null) {\n\t\t\t\t\tlogger.warning(\"Branch '\" + branchName + \"' already exists\");\n\t\t\t\t} else {\n\t\t\t\t\tString branchRevision = getBranchRevision();\n\t\t\t\t\tif (branchRevision == null)\n\t\t\t\t\t\tbranchRevision = build.getCommitHash();\n\t\t\t\t\tOneDev.getInstance(GitService.class).createBranch(project, branchName, branchRevision);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlogger.error(\"This build is not authorized to create branch '\" + branchName + \"'\");\n\t\t\t\treturn new ServerStepResult(false);\n\t\t\t}\n\t\t\treturn new ServerStepResult(true);","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/step/CreateBranchStep.java#L85-L121","documentation":"Guard in CreateBranchStep.run: the step's branch-name property evaluated (after variable interpolation) to a blank string, so there is no name to create the branch with; ExplicitException fails the build step. Fix: set the branch name property or fix the variable/secret it references so it resolves to a non-empty value.","triggerScenarios":"Thrown at server-core/src/main/java/io/onedev/server/buildspec/step/CreateBranchStep.java:103 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the branch name provider (script/variable) returns a non-empty name for this build.","Fix the upstream condition that left the name variable empty."],"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-14T00:17:10.932Z"}