theonedev/onedev · error · ExplicitException

Source branch should not be empty

Error message

Source branch should not be empty

What it means

Guard in CreatePullRequestStep.run: the source branch property is blank after interpolation, so the pull request cannot be created from an unknown source; ExplicitException fails the step. Fix: define the source branch (check the property and any variables it uses).

Source

Thrown at server-core/src/main/java/io/onedev/server/buildspec/step/CreatePullRequestStep.java:121

		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 {
					pullRequest = new PullRequest();
					pullRequest.setTarget(target);

View on GitHub (pinned to d44925c47c)

Solutions

  1. Set an explicit source branch in the step configuration.
  2. Ensure the variable/script supplying the source branch yields a value.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server-core/src/main/java/io/onedev/server/buildspec/step/CreatePullRequestStep.java:121 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/98511d4a40a94bbd. Report an issue: GitHub.