{"record":{"id":"7087f8e21a8b0cf4","repo":"elastic/elasticsearch","slug":"no-new-version-added-to-set-as-the-current-version","errorCode":null,"errorMessage":"No new version added to set as the current version","messagePattern":"No new version added to set as the current version","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/UpdateVersionsTask.java","lineNumber":94,"sourceCode":"        return String.format(\"V_%d_%d_%d\", version.getMajor(), version.getMinor(), version.getRevision());\n    }\n\n    static Optional<Version> parseVersionField(CharSequence field) {\n        Matcher m = VERSION_FIELD.matcher(field);\n        if (m.find() == false) return Optional.empty();\n\n        return Optional.of(\n            new Version(Integer.parseInt(m.group(1)), Integer.parseInt(m.group(2)), Integer.parseInt(m.group(3)), m.group(4))\n        );\n    }\n\n    @TaskAction\n    public void executeTask() throws IOException {\n        if (addVersion == null && removeVersion == null) {\n            throw new IllegalArgumentException(\"No versions to add or remove specified\");\n        }\n        if (setCurrent && addVersion == null) {\n            throw new IllegalArgumentException(\"No new version added to set as the current version\");\n        }\n        if (addVersion != null && removeVersion != null && Objects.equals(addVersion, removeVersion)) {\n            throw new IllegalArgumentException(\"Same version specified to add and remove\");\n        }\n\n        Path versionJava = rootDir.resolve(VERSION_FILE_PATH);\n        CompilationUnit file = LexicalPreservingPrinter.setup(StaticJavaParser.parse(versionJava));\n\n        Optional<CompilationUnit> modifiedFile = Optional.empty();\n        if (addVersion != null) {\n            LOGGER.lifecycle(\"Adding new version [{}] to [{}]\", addVersion, versionJava);\n            var added = addVersionConstant(modifiedFile.orElse(file), addVersion, setCurrent);\n            if (added.isPresent()) {\n                modifiedFile = added;\n            }\n        }\n        if (removeVersion != null) {\n            LOGGER.lifecycle(\"Removing version [{}] from [{}]\", removeVersion, versionJava);","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/UpdateVersionsTask.java#L76-L112","documentation":"Thrown by UpdateVersionsTask.executeTask() when --set-current was requested but addVersion is null. CURRENT can only be repointed to a newly added version, so the combination is invalid.","triggerScenarios":"Passing --set-current together with only --remove-version, or with no --add-version at all.","commonSituations":"Operator copies a command template and forgets the --add-version while keeping --set-current; CI flag wiring dropped --add-version.","solutions":["Always pair --set-current with an --add-version, e.g. --add-version=8.10.0 --set-current.","If you only meant to remove a version, drop --set-current."],"exampleFix":"// before\n./gradlew updateVersions --set-current\n\n// after\n./gradlew updateVersions --add-version=8.10.0 --set-current","handlingStrategy":"validation","validationCode":"// Enforce the --set-current + --add-version contract up front\nboolean setCurrent = providers.gradleProperty(\"set-current\").isPresent();\nboolean hasAdd = providers.gradleProperty(\"add-version\").isPresent();\nif (setCurrent && !hasAdd) {\n    throw new GradleException(\"--set-current requires --add-version\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always issue --set-current together with --add-version in the release template.","Lint the option combination before running the task."],"tags":["release-tooling","gradle-task","option-conflict","precondition"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}