{"record":{"id":"c0f11eb825f332aa","repo":"elastic/elasticsearch","slug":"no-version-ids-found-in-javaversionsfile","errorCode":null,"errorMessage":"No version ids found in {javaVersionsFile}","messagePattern":"No version ids found in (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/ExtractCurrentVersionsTask.java","lineNumber":90,"sourceCode":"        @Override\n        public void accept(FieldDeclaration fieldDeclaration) {\n            findSingleIntegerExpr(fieldDeclaration).ifPresent(id -> {\n                if (highestVersionId != null && highestVersionId > id) {\n                    LOGGER.warn(\"Version ids [{}, {}] out of order\", highestVersionId, id);\n                } else {\n                    highestVersionId = id;\n                }\n            });\n        }\n    }\n\n    private static int readLatestVersion(Path javaVersionsFile) throws IOException {\n        CompilationUnit java = StaticJavaParser.parse(javaVersionsFile);\n\n        FieldIdExtractor extractor = new FieldIdExtractor();\n        java.walk(FieldDeclaration.class, extractor);   // walks in code file order\n        if (extractor.highestVersionId == null) {\n            throw new IllegalArgumentException(\"No version ids found in \" + javaVersionsFile);\n        }\n        return extractor.highestVersionId;\n    }\n}\n","sourceCodeStart":72,"sourceCodeEnd":95,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/ExtractCurrentVersionsTask.java#L72-L95","documentation":"Thrown by ExtractCurrentVersionsTask.readLatestVersion after walking all FieldDeclaration nodes in the parsed Version.java file via a FieldIdExtractor. If the extractor's highestVersionId remains null (no field yielded an integer id), the file did not contain any recognizable version-id field declarations and the task cannot determine the latest version.","triggerScenarios":"StaticJavaParser parses the javaVersionsFile (typically Version.java) and a FieldIdExtractor walks its FieldDeclarations looking for integer literals. If none matched the extractor's criteria (e.g. all candidate fields have zero or multiple integer literals, or the file structure changed), highestVersionId stays null and the throw fires.","commonSituations":"Version.java was refactored so version ids are no longer simple integer literal fields (e.g. moved to a map, computed, or annotated in a new way); the file path constant points at the wrong file; the extractor's matching logic didn't evolve with the source format; a parsing edge case where a version field has multiple integer literals and is skipped per findSingleIntegerExpr's default branch.","solutions":["Open the named javaVersionsFile and confirm it still contains simple `public static final int <NAME> = <int>;` version-id fields.","If a field legitimately contains multiple integer literals, it is intentionally skipped (logged as a warning) — ensure at least one single-integer field exists for the extractor to use.","If the file format changed, update FieldIdExtractor / findSingleIntegerExpr to match the new structure rather than weakening the check.","Verify the file path constant INDEX_VERSIONS_FILE_PATH / passed path points at the correct source file."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// After extraction, ensure a result was found\nif (extractor.highestVersionId == null) {\n    throw new IllegalStateException(\"No version ids parsed from \" + javaVersionsFile\n        + \" — verify the file still contains simple int literal version fields\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep Version.java version ids as simple `int` literal fields.","Update the extractor when the source format changes.","Add a unit test that parses the canonical Version.java to catch format drift."],"tags":["build","gradle","release","versioning","javaparser"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}