elastic/elasticsearch · error · IllegalArgumentException

'branch' not specified.

Error message

'branch' not specified.

What it means

Thrown by BundleChangelogsTask.executeTask when the --branch option was not supplied. The bundling logic needs a target branch (and optionally a --bc-ref) to know which changelog YAML files to collect; with branch == null the task cannot proceed and aborts immediately.

Source

Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/BundleChangelogsTask.java:139

    /*
        Given a branch, and possibly a build candidate commit sha
        Check out the changelog yaml files from the branch/BC sha
        Then, bundle them all up into one file and write it to disk, along with a timestamp and whether the release is considered released

         When using a branch without a BC sha:
            - Check out the changelog yaml files from the HEAD of the branch

         When using a BC sha:
            - Check out the changelog yaml files from the BC commit
            - Update those files with any updates from the HEAD of the branch (in case the changelogs get modified later)
            - Check for any changelog yaml files that were added AFTER the BC,
              but whose PR was merged before the BC (in case someone adds a forgotten changelog after the fact)
    */
    @TaskAction
    public void executeTask() throws IOException {
        if (branch == null) {
            throw new IllegalArgumentException("'branch' not specified.");
        }

        final String upstreamRemote = gitWrapper.getUpstream();
        final String esBcRefForGit = (bcRef != null && bcRef.isBlank() == false) ? resolveElasticsearchGitRef(bcRef, upstreamRemote) : null;
        Set<String> entriesFromBc = Set.of();

        var didCheckoutChangelogs = false;
        try {
            var usingBcRef = bcRef != null && bcRef.isBlank() == false;
            if (usingBcRef) {
                // Check out all the changelogs that existed at the time of the BC
                checkoutChangelogs(gitWrapper, upstreamRemote, bcRef);
                entriesFromBc = changelogDirectory.getAsFileTree().getFiles().stream().map(File::getName).collect(Collectors.toSet());

                // Then add/update changelogs from the HEAD of the branch
                // We do an "add" here, rather than checking out the entire directory, in case changelogs have been removed for some reason
                addChangelogsFromRef(gitWrapper, upstreamRemote, branch);
            } else {

View on GitHub (pinned to db6a809a66)

Solutions

  1. Add --branch <branchName> to the task invocation (e.g. ./gradlew bundleChangelogs --branch 8.x).
  2. If a build candidate ref is intended, also pass --bc-ref <sha> (optional, but --branch is always required).
  3. Update any release automation script to always supply --branch.

Example fix

// before
./gradlew bundleChangelogs
// after
./gradlew bundleChangelogs --branch 8.x
Defensive patterns

Strategy: validation

Validate before calling

if (branch == null || branch.isBlank()) {
    throw new IllegalArgumentException("--branch is required for bundleChangelogs");
}

Prevention

When it happens

Trigger: Invoking the bundleChangelogs task without the --branch command-line option. The task's executeTask checks `if (branch == null)` first thing and throws IllegalArgumentException before doing any git work.

Common situations: Running the release changelog-bundling Gradle task manually and forgetting --branch; a release script changed and dropped the flag; invoking via a wrapper that conditionally passes --branch only on some branches and ran on one without it.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/ce3d28a6d52dd1b3. Report an issue: GitHub.