{"record":{"id":"0929cb6b65ba282e","repo":"theonedev/onedev","slug":"invalid-branch-name","errorCode":null,"errorMessage":"Invalid branch name: ","messagePattern":"Invalid branch name: ","errorType":"validation","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/step/CreateBranchStep.java","lineNumber":105,"sourceCode":"\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);\n\t\t});\n\t}","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/step/CreateBranchStep.java#L87-L123","documentation":"CreateBranchStep checks the computed branch name with Repository.isValidRefName and fails the step when it is not a valid git ref name; the message carries the offending name. This is a build-step guard, not a git failure.","triggerScenarios":"Thrown at server-core/src/main/java/io/onedev/server/buildspec/step/CreateBranchStep.java:105 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove invalid characters (spaces, ~ ^ : ? * [ \\, consecutive dots, leading/trailing slashes) from the branch name.","Sanitize names derived from issue titles or variables before creating the branch."],"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"}