{"record":{"id":"a61640fc80eece99","repo":"elastic/elasticsearch","slug":"no-versions-to-add-or-remove-specified","errorCode":null,"errorMessage":"No versions to add or remove specified","messagePattern":"No versions to add or remove specified","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/UpdateVersionsTask.java","lineNumber":91,"sourceCode":"    }\n\n    static String toVersionField(Version version) {\n        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            }","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/UpdateVersionsTask.java#L73-L109","documentation":"Thrown by UpdateVersionsTask.executeTask() when both addVersion and removeVersion are null. At least one operation is required for the task to do anything.","triggerScenarios":"Invoking updateVersions with neither --add-version nor --remove-version.","commonSituations":"A release script conditionally supplies the options and supplied none; options were misnamed in CI config.","solutions":["Pass at least one of --add-version=<version> or --remove-version=<version>.","Audit the release automation to confirm the branch that supplies these options is taken."],"exampleFix":"// before\n./gradlew updateVersions\n\n// after\n./gradlew updateVersions --add-version=8.10.0","handlingStrategy":"validation","validationCode":"// Assert at least one operation is supplied\ntasks.named('updateVersions').configure(t -> t.doFirst(spec -> {\n    var p = spec.getProviders();\n    if (!p.gradleProperty(\"add-version\").forUseAtConfigurationTime().isPresent()\n        && !p.gradleProperty(\"remove-version\").forUseAtConfigurationTime().isPresent()) {\n        throw new GradleException(\"--add-version or --remove-version is required\");\n    }\n}));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize the version-bump command in one script that always sets --add-version."],"tags":["release-tooling","gradle-task","missing-option","precondition"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}