elastic/elasticsearch · error · InvalidUserDataException
Branch {branch} does not exist
Error message
Branch {branch} does not exist What it means
Thrown by UpdateBranchesJsonTask.executeTask() in the removeBranch path when no branch with the given name exists in branches.json.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/UpdateBranchesJsonTask.java:134
@TaskAction
public void executeTask() throws IOException {
List<DevelopmentBranch> developmentBranches = readBranches(branchesFile);
if (addBranch == null && removeBranch == null && updateBranch == null) {
throw new InvalidUserDataException("At least one of add-branch, remove-branch or update-branch must be specified");
}
if (addBranch != null) {
LOGGER.info("Adding branch {} with version {}", addBranch.name(), addBranch.version());
if (developmentBranches.stream().anyMatch(developmentBranch -> developmentBranch.name().equals(addBranch.name()))) {
throw new InvalidUserDataException("Branch " + addBranch.name() + " already exists");
}
developmentBranches.add(addBranch);
}
if (removeBranch != null) {
LOGGER.info("Removing branch {}", removeBranch);
if (developmentBranches.stream().noneMatch(developmentBranch -> developmentBranch.name().equals(removeBranch))) {
throw new InvalidUserDataException("Branch " + removeBranch + " does not exist");
}
developmentBranches.removeIf(developmentBranch -> developmentBranch.name().equals(removeBranch));
}
if (updateBranch != null) {
LOGGER.info("Updating branch {} with version {}", updateBranch.name(), updateBranch.version());
if (developmentBranches.stream().noneMatch(developmentBranch -> developmentBranch.name().equals(updateBranch.name()))) {
throw new InvalidUserDataException("Branch " + updateBranch.name() + " does not exist");
}
developmentBranches.removeIf(developmentBranch -> developmentBranch.name().equals(updateBranch.name()));
developmentBranches.add(updateBranch);
}
developmentBranches.sort(Comparator.comparing(DevelopmentBranch::version).reversed());
JsonNode jsonNode = objectMapper.readTree(new FileInputStream(branchesFile));
ArrayNode updatedBranches = objectMapper.createArrayNode();
for (DevelopmentBranch branch : developmentBranches) {
ObjectNode objectNode = objectMapper.createObjectNode();View on GitHub (pinned to db6a809a66)
Solutions
- Check the branch names currently in branches.json and correct the --remove-branch argument.
- If the branch is genuinely gone, no further action is needed.
Example fix
// before ./gradlew updateBranches --remove-branch=8.x # actual name is 8.10 // after ./gradlew updateBranches --remove-branch=8.10
Defensive patterns
Strategy: validation
Validate before calling
// Confirm the branch exists before issuing --remove-branch
static boolean branchExists(Path branchesFile, String name) throws IOException {
return new ObjectMapper().readTree(branchesFile.toFile())
.path("branches").findValuesAsText("branch").contains(name);
} Prevention
- Read branches.json first and pick the exact name to remove.
- Make removal idempotent: tolerate 'already absent'.
When it happens
Trigger: Running --remove-branch=<name> for a name not present in branches.json (typo, already removed, wrong repo state).
Common situations: Operator typo in the branch name; the branch was never added; a prior remove already succeeded; the local branches.json is stale.
Related errors
- Branch {branch} already exists
- File branches.json has not been found in {path}
- Release version not specified
- No version tags specified
- Unknown version type {key}
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/02e4eab3e5643de2.
Report an issue: GitHub.