{"record":{"id":"fbc9d182188c144b","repo":"elastic/elasticsearch","slug":"no-read-only-compatible-version-found","errorCode":null,"errorMessage":"No read-only compatible version found.","messagePattern":"No read-only compatible version found\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BwcVersions.java","lineNumber":216,"sourceCode":"    }\n\n    public List<Version> getReleased() {\n        return versions.stream()\n            .filter(v -> v.getMajor() >= currentVersion.getMajor() - 1)\n            .filter(v -> unreleased.containsKey(v) == false)\n            .toList();\n    }\n\n    public List<Version> getReadOnlyIndexCompatible() {\n        // Lucene can read indices in version N-2\n        int compatibleMajor = currentVersion.getMajor() - 2;\n        return versions.stream().filter(v -> v.getMajor() == compatibleMajor).sorted(Comparator.naturalOrder()).toList();\n    }\n\n    public void withLatestReadOnlyIndexCompatible(Consumer<Version> versionAction) {\n        var compatibleVersions = getReadOnlyIndexCompatible();\n        if (compatibleVersions == null || compatibleVersions.isEmpty()) {\n            throw new IllegalStateException(\"No read-only compatible version found.\");\n        }\n        versionAction.accept(compatibleVersions.getLast());\n    }\n\n    /**\n     * Return versions of Elasticsearch which are index compatible with the current version.\n     */\n    public List<Version> getIndexCompatible() {\n        return versions.stream().filter(v -> v.getMajor() >= (currentVersion.getMajor() - 1)).toList();\n    }\n\n    public void withIndexCompatible(BiConsumer<Version, String> versionAction) {\n        getIndexCompatible().forEach(v -> versionAction.accept(v, \"v\" + v.toString()));\n    }\n\n    public void withIndexCompatible(Predicate<Version> filter, BiConsumer<Version, String> versionAction) {\n        getIndexCompatible().stream().filter(filter).forEach(v -> versionAction.accept(v, \"v\" + v.toString()));\n    }","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BwcVersions.java#L198-L234","documentation":"Thrown by BwcVersions.withLatestReadOnlyIndexCompatible when getReadOnlyIndexCompatible() returns null or an empty list. Lucene can read indices from N-2 majors; this fires when no version two majors below the current one is registered in the parsed version set.","triggerScenarios":"The current major is so new (or the version list is so truncated) that no N-2 major version exists in the parsed list, so getReadOnlyIndexCompatible filters down to nothing.","commonSituations":"Very early in a new major cycle before N-2 versions are populated; version parsing returned a partial list; corrupt or truncated Version.java.","solutions":["Ensure N-2 major versions are present in Version.java so the read-only-compatible set is non-empty.","Verify version parsing returned the full historical list (see error 130 causes).","Confirm the current major is correctly configured in build properties."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"List<Version> compatible = getReadOnlyIndexCompatible();\nif (compatible == null || compatible.isEmpty()) {\n    throw new IllegalStateException(\"No read-only compatible version found.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure Version.java includes N-2 major versions before relying on read-only compat checks.","Validate the parsed version list is complete (see error 130).","Guard callers of withLatestReadOnlyIndexCompatible against an empty compatible set."],"tags":["bwc","lucene","index-compat","build-tools"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}