elastic/elasticsearch · error · IllegalStateException

Unable to resolve to resolve bwc versions from versionsFile.

Error message

Unable to resolve to resolve bwc versions from versionsFile.

What it means

Thrown by GlobalBuildInfoPlugin.resolveBwcVersions(Version) when reading the backwards-compatibility (BWC) versions source file fails with IOException. The file path is resolved from the BWC_VERSION_SOURCE system property or defaults to a Java file (DEFAULT_VERSION_JAVA_FILE_PATH) in the Elasticsearch workspace. The IOException is wrapped in IllegalStateException. Note: the error message contains a typo ('Unable to resolve to resolve').

Source

Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java:203

    private String formatJavaVendorDetails(JvmInstallationMetadata runtimeJdkMetaData) {
        JvmVendor vendor = runtimeJdkMetaData.getVendor();
        return runtimeJdkMetaData.getVendor().getKnownVendor().name() + "/" + vendor.getRawVendor();
    }

    /* Introspect all versions of ES that may be tested against for backwards
     * compatibility. It is *super* important that this logic is the same as the
     * logic in VersionUtils.java. */
    private BwcVersions resolveBwcVersions(Version currentElasticsearchVersion) {
        String versionsFilePath = elvis(
            System.getProperty("BWC_VERSION_SOURCE"),
            new File(Util.locateElasticsearchWorkspace(project.getGradle()), DEFAULT_VERSION_JAVA_FILE_PATH).getPath()
        );
        try (var is = new FileInputStream(versionsFilePath)) {
            List<String> versionLines = IOUtils.readLines(is, "UTF-8");
            return new BwcVersions(currentElasticsearchVersion, parseVersionLines(versionLines), getDevelopmentBranches());
        } catch (IOException e) {
            throw new IllegalStateException("Unable to resolve to resolve bwc versions from versionsFile.", e);
        }
    }

    private List<Version> parseVersionLines(List<String> versionLines) {
        return versionLines.stream()
            .map(LINE_PATTERN::matcher)
            .filter(Matcher::matches)
            .map(match -> new Version(Integer.parseInt(match.group(1)), Integer.parseInt(match.group(2)), Integer.parseInt(match.group(3))))
            .sorted()
            .toList();
    }

    private List<DevelopmentBranch> getDevelopmentBranches() {
        String configuredBranchesFileLocation = project.getProviders()
            .gradleProperty(BRANCHES_FILE_LOCATION_PROPERTY)
            .getOrElse(DEFAULT_BRANCHES_FILE_URL);
        String branchesFileLocation = configuredBranchesFileLocation;
        if (project.getGradle().getStartParameter().isOffline() && isHttpLocation(configuredBranchesFileLocation)) {

View on GitHub (pinned to db6a809a66)

Solutions

  1. If BWC_VERSION_SOURCE is set, verify the path exists and is readable: test -r $BWC_VERSION_SOURCE.
  2. Unset BWC_VERSION_SOURCE to fall back to the default path in the workspace.
  3. Verify Util.locateElasticsearchWorkspace resolves correctly by checking the Gradle project root matches the Elasticsearch repo root.
  4. If the default Version.java path changed, update DEFAULT_VERSION_JAVA_FILE_PATH in the plugin source.

Example fix

# before
./gradlew build -DBWC_VERSION_SOURCE=/old/path/Version.java

# after (valid path or unset)
./gradlew build -DBWC_VERSION_SOURCE=/correct/path/to/Version.java
# or simply omit to use default
./gradlew build
Defensive patterns

Strategy: validation

Validate before calling

// Validate BWC version source file before reading
String path = System.getProperty("BWC_VERSION_SOURCE");
if (path != null) {
    File f = new File(path);
    if (!f.exists() || !f.canRead()) {
        throw new GradleException("BWC_VERSION_SOURCE does not exist or is unreadable: " + path);
    }
}

Prevention

When it happens

Trigger: System.getProperty('BWC_VERSION_SOURCE') is set to a non-existent or unreadable file path, or the default path (Util.locateElasticsearchWorkspace + DEFAULT_VERSION_JAVA_FILE_PATH) cannot be read. The FileInputStream constructor or IOUtils.readLines throws IOException.

Common situations: BWC_VERSION_SOURCE is set to a stale path after a repository restructure. The workspace detection (Util.locateElasticsearchWorkspace) fails to find the Elasticsearch root, producing a path that doesn't exist. A composite build setup causes the workspace to be located differently. The default Version.java file was renamed or moved in a newer branch.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/435dbf9b5f69de17. Report an issue: GitHub.