{"record":{"id":"c44a8099a66b49cb","repo":"elastic/elasticsearch","slug":"expected-branch-and-version-in-format-branch-ve","errorCode":null,"errorMessage":"Expected branch and version in format <branch>:<version>","messagePattern":"Expected branch and version in format <branch>:<version>","errorType":"validation","errorClass":"InvalidUserDataException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/UpdateBranchesJsonTask.java","lineNumber":111,"sourceCode":"    @Option(option = \"add-branch\", description = \"Specifies the branch and corresponding version to add in format <branch>:<version>\")\n    public void addBranch(String branchAndVersion) {\n        this.addBranch = toDevelopmentBranch(branchAndVersion);\n    }\n\n    @Option(option = \"remove-branch\", description = \"Specifies the branch to remove\")\n    public void removeBranch(String branch) {\n        this.removeBranch = branch;\n    }\n\n    @Option(option = \"update-branch\", description = \"Specifies the branch and corresponding version to update in format <branch>:<version>\")\n    public void updateBranch(String branchAndVersion) {\n        this.updateBranch = toDevelopmentBranch(branchAndVersion);\n    }\n\n    private DevelopmentBranch toDevelopmentBranch(String branchAndVersion) {\n        String[] parts = branchAndVersion.split(\":\");\n        if (parts.length != 2) {\n            throw new InvalidUserDataException(\"Expected branch and version in format <branch>:<version>\");\n        }\n        return new DevelopmentBranch(parts[0], Version.fromString(parts[1]));\n    }\n\n    @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);","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/UpdateBranchesJsonTask.java#L93-L129","documentation":"Thrown by UpdateBranchesJsonTask.toDevelopmentBranch() when the --update-branch argument, split on ':', does not yield exactly two parts. The argument must be <branch>:<version>.","triggerScenarios":"Passing --update-branch with no colon, more than one colon, or an empty string; a version containing a colon would also push the part count past 2.","commonSituations":"Shell quoting swallowed the colon; a template variable produced an empty value; the branch or version string itself contains a colon.","solutions":["Pass exactly two colon-separated tokens, e.g. --update-branch=8.10:8.10.0.","Ensure neither the branch name nor the version legitimately contains a colon; if a version ever did, the splitter would need updating.","Quote the argument so the shell does not interpret the colon."],"exampleFix":"// before\n./gradlew updateBranches --update-branch=8.10\n\n// after\n./gradlew updateBranches --update-branch=8.10:8.10.0","handlingStrategy":"validation","validationCode":"// Validate the --update-branch token shape before invoking the task\nstatic String normalizeBranchArg(String arg) {\n    String[] parts = arg.split(\":\");\n    if (parts.length != 2 || parts[0].isBlank() || parts[1].isBlank()) {\n        throw new IllegalArgumentException(\"Expected <branch>:<version>, got \" + arg);\n    }\n    return arg;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass branch and version as a single quoted <branch>:<version> token.","Shell-quote the argument to preserve the colon."],"tags":["release-tooling","gradle-task","option-parsing","precondition"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}