theonedev/onedev · error · ExplicitException
Branch name should not be empty
Error message
Branch name should not be empty
What it means
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.
Source
Thrown at server-core/src/main/java/io/onedev/server/buildspec/step/CreateBranchStep.java:103
public void setAccessTokenSecret(String accessTokenSecret) {
this.accessTokenSecret = accessTokenSecret;
}
@SuppressWarnings("unused")
private static List<String> getAccessTokenSecretChoices() {
return Project.get().getHierarchyJobSecrets()
.stream().map(it->it.getName()).collect(Collectors.toList());
}
@Override
public ServerStepResult run(Long buildId, File inputDir, TaskLogger logger) {
return OneDev.getInstance(SessionService.class).call(() -> {
var build = OneDev.getInstance(BuildService.class).load(buildId);
Project project = build.getProject();
String branchName = branchNameProvider.getBranchName(build);
if (StringUtils.isBlank(branchName))
throw new ExplicitException("Branch name should not be empty");
if (!Repository.isValidRefName(GitUtils.branch2ref(branchName)))
throw new ExplicitException("Invalid branch name: " + branchName);
if (build.canCreateBranch(getAccessTokenSecret(), branchName)) {
RefFacade branchRef = project.getBranchRef(branchName);
if (branchRef != null) {
logger.warning("Branch '" + branchName + "' already exists");
} else {
String branchRevision = getBranchRevision();
if (branchRevision == null)
branchRevision = build.getCommitHash();
OneDev.getInstance(GitService.class).createBranch(project, branchName, branchRevision);
}
} else {
logger.error("This build is not authorized to create branch '" + branchName + "'");
return new ServerStepResult(false);
}
return new ServerStepResult(true);View on GitHub (pinned to d44925c47c)
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.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at server-core/src/main/java/io/onedev/server/buildspec/step/CreateBranchStep.java:103 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/a78e0b2442c8c82e.
Report an issue: GitHub.