{"record":{"id":"02e4eab3e5643de2","repo":"elastic/elasticsearch","slug":"branch-branch-does-not-exist","errorCode":null,"errorMessage":"Branch {branch} does not exist","messagePattern":"Branch (.+?) does not exist","errorType":"validation","errorClass":"InvalidUserDataException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/UpdateBranchesJsonTask.java","lineNumber":134,"sourceCode":"    @TaskAction\n    public void executeTask() throws IOException {\n        List<DevelopmentBranch> developmentBranches = readBranches(branchesFile);\n\n        if (addBranch == null && removeBranch == null && updateBranch == null) {\n            throw new InvalidUserDataException(\"At least one of add-branch, remove-branch or update-branch must be specified\");\n        }\n\n        if (addBranch != null) {\n            LOGGER.info(\"Adding branch {} with version {}\", addBranch.name(), addBranch.version());\n            if (developmentBranches.stream().anyMatch(developmentBranch -> developmentBranch.name().equals(addBranch.name()))) {\n                throw new InvalidUserDataException(\"Branch \" + addBranch.name() + \" already exists\");\n            }\n            developmentBranches.add(addBranch);\n        }\n        if (removeBranch != null) {\n            LOGGER.info(\"Removing branch {}\", removeBranch);\n            if (developmentBranches.stream().noneMatch(developmentBranch -> developmentBranch.name().equals(removeBranch))) {\n                throw new InvalidUserDataException(\"Branch \" + removeBranch + \" does not exist\");\n            }\n            developmentBranches.removeIf(developmentBranch -> developmentBranch.name().equals(removeBranch));\n        }\n        if (updateBranch != null) {\n            LOGGER.info(\"Updating branch {} with version {}\", updateBranch.name(), updateBranch.version());\n            if (developmentBranches.stream().noneMatch(developmentBranch -> developmentBranch.name().equals(updateBranch.name()))) {\n                throw new InvalidUserDataException(\"Branch \" + updateBranch.name() + \" does not exist\");\n            }\n            developmentBranches.removeIf(developmentBranch -> developmentBranch.name().equals(updateBranch.name()));\n            developmentBranches.add(updateBranch);\n        }\n\n        developmentBranches.sort(Comparator.comparing(DevelopmentBranch::version).reversed());\n\n        JsonNode jsonNode = objectMapper.readTree(new FileInputStream(branchesFile));\n        ArrayNode updatedBranches = objectMapper.createArrayNode();\n        for (DevelopmentBranch branch : developmentBranches) {\n            ObjectNode objectNode = objectMapper.createObjectNode();","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/UpdateBranchesJsonTask.java#L116-L152","documentation":"Thrown by UpdateBranchesJsonTask.executeTask() in the removeBranch path when no branch with the given name exists in branches.json.","triggerScenarios":"Running --remove-branch=<name> for a name not present in branches.json (typo, already removed, wrong repo state).","commonSituations":"Operator typo in the branch name; the branch was never added; a prior remove already succeeded; the local branches.json is stale.","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."],"exampleFix":"// before\n./gradlew updateBranches --remove-branch=8.x   # actual name is 8.10\n\n// after\n./gradlew updateBranches --remove-branch=8.10","handlingStrategy":"validation","validationCode":"// Confirm the branch exists before issuing --remove-branch\nstatic boolean branchExists(Path branchesFile, String name) throws IOException {\n    return new ObjectMapper().readTree(branchesFile.toFile())\n        .path(\"branches\").findValuesAsText(\"branch\").contains(name);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read branches.json first and pick the exact name to remove.","Make removal idempotent: tolerate 'already absent'."],"tags":["release-tooling","gradle-task","not-found","branches-json"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}