theonedev/onedev · error · ExplicitException
Target branch should not be empty
Error message
Target branch should not be empty
What it means
CreatePullRequestStep.run validates that the resolved target branch is non-empty before opening a pull request; an empty value means the targetBranch setting (possibly variable-based) evaluated to nothing.
Source
Thrown at server-core/src/main/java/io/onedev/server/buildspec/step/CreatePullRequestStep.java:119
@SuppressWarnings("unused")
private static List<InputSuggestion> suggestVariables(String matchWith) {
return BuildSpec.suggestVariables(matchWith, true, true, false);
}
@SuppressWarnings("unused")
private static List<InputSuggestion> suggestRevisions(String matchWith) {
Project project = Project.get();
if (project != null)
return SuggestionUtils.suggestRevisions(project, matchWith);
else
return new ArrayList<>();
}
@Override
public ServerStepResult run(Long buildId, File inputDir, TaskLogger logger) {
return OneDev.getInstance(SessionService.class).call(() -> {
if (StringUtils.isBlank(getTargetBranch()))
throw new ExplicitException("Target branch should not be empty");
if (StringUtils.isBlank(getSourceBranch()))
throw new ExplicitException("Source branch should not be empty");
var build = OneDev.getInstance(BuildService.class).load(buildId);
var projectId = build.getProject().getId();
ProjectAndBranch target = new ProjectAndBranch(projectId, getTargetBranch());
ProjectAndBranch source = new ProjectAndBranch(projectId, getSourceBranch());
if (target.equals(source)) {
logger.warning("Pull request will not be created as target branch is the same as source branch");
} else {
var pullRequestService = OneDev.getInstance(PullRequestService.class);
var pullRequest = pullRequestService.findOpen(target, source);
if (pullRequest != null) {
logger.warning("A pull request has already been opened for specified branches");
} else {View on GitHub (pinned to d44925c47c)
Solutions
- Set an explicit target branch in the step configuration.
- Fix the variable/script that should supply the target branch name.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at server-core/src/main/java/io/onedev/server/buildspec/step/CreatePullRequestStep.java:119 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/0f327dd967c76bec.
Report an issue: GitHub.