theonedev/onedev · error · ExplicitException
Invalid branch name:
Error message
Invalid branch name:
What it means
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.
Source
Thrown at server-core/src/main/java/io/onedev/server/buildspec/step/CreateBranchStep.java:105
}
@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
- 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.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at server-core/src/main/java/io/onedev/server/buildspec/step/CreateBranchStep.java:105 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/0929cb6b65ba282e.
Report an issue: GitHub.