elastic/elasticsearch · error · GradleException
tests.bwc.git_fetch_latest must be [true] or [false] but was
Error message
tests.bwc.git_fetch_latest must be [true] or [false] but was [${fetchProp}] What it means
Thrown as GradleException inside the fetchLatest task configuration when the system property tests.bwc.git_fetch_latest is set to a value other than "true" or "false". The property controls whether the BWC git checkout fetches latest from remotes; the provider maps the string to a boolean and rejects anything ambiguous rather than silently defaulting.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalBwcGitPlugin.java:123
// for testing only we can override the base remote url
String remoteRepoUrl = providerFactory.systemProperty("testRemoteRepo")
.getOrElse("https://github.com/" + remoteRepo + "/" + rootProjectName);
spec.commandLine("git", "remote", "add", remoteRepo, remoteRepoUrl);
});
}
});
});
boolean isOffline = project.getGradle().getStartParameter().isOffline();
TaskProvider<LoggedExec> fetchLatestTaskProvider = tasks.register("fetchLatest", LoggedExec.class, fetchLatest -> {
var gitFetchLatest = providerFactory.systemProperty("tests.bwc.git_fetch_latest").orElse("true").map(fetchProp -> {
if ("true".equals(fetchProp)) {
return true;
}
if ("false".equals(fetchProp)) {
return false;
}
throw new GradleException("tests.bwc.git_fetch_latest must be [true] or [false] but was [" + fetchProp + "]");
});
fetchLatest.onlyIf("DRA snapshot not available", task -> draBuildId.get().isEmpty());
fetchLatest.onlyIf("online and gitFetchLatest == true", t -> isOffline == false && gitFetchLatest.get());
fetchLatest.dependsOn(addRemoteTaskProvider);
fetchLatest.getWorkingDir().set(gitExtension.getCheckoutDir());
// Fetch latest from remotes, including tags, overriding any existing local refs
fetchLatest.commandLine("git", "fetch", "--all", "--tags", "--force");
});
String projectPath = project.getPath();
TaskProvider<Task> checkoutBwcBranchTaskProvider = tasks.register("checkoutBwcBranch", checkoutBwcBranch -> {
checkoutBwcBranch.dependsOn(fetchLatestTaskProvider);
checkoutBwcBranch.onlyIf("DRA snapshot not available", task -> draBuildId.get().isEmpty());
ExtraPropertiesExtension taskExtensionsProperties = checkoutBwcBranch.getExtensions().getExtraProperties();
checkoutBwcBranch.doLast(new Action<Task>() {
@Override
public void execute(Task task) {
File checkoutDir = gitExtension.getCheckoutDir().get();View on GitHub (pinned to db6a809a66)
Solutions
- Set the property to exactly true or false (lowercase): -Dtests.bwc.git_fetch_latest=false.
- Omit the property entirely to accept the default (true).
- Check the CI/shell script for unquoted variables or trailing whitespace that corrupts the value.
Example fix
# before ./gradlew bwcTest -Dtests.bwc.git_fetch_latest=1 # after ./gradlew bwcTest -Dtests.bwc.git_fetch_latest=false
Defensive patterns
Strategy: validation
Validate before calling
String v = System.getProperty("tests.bwc.git_fetch_latest", "true");
if ("true".equalsIgnoreCase(v) == false && "false".equalsIgnoreCase(v) == false) {
throw new IllegalArgumentException("Invalid value for tests.bwc.git_fetch_latest: " + v);
} Prevention
- Always use lowercase 'true' or 'false' for tests.bwc.git_fetch_latest.
- Quote shell variables when passing system properties in CI scripts.
- Omit the property to accept the default (true) when in doubt.
- Validate property values in a pre-check script before invoking Gradle.
When it happens
Trigger: At line 116 the providerFactory resolves tests.bwc.git_fetch_latest (defaulting to "true") and runs a map that checks for exactly "true" or "false". Passing -Dtests.bwc.git_fetch_latest=yes, =1, =TRUE (case-sensitive), or an empty trailing value triggers the throw at line 123.
Common situations: Developer passes -Dtests.bwc.git_fetch_latest=1 or =yes expecting truthiness; CI script sets the property from an unquoted shell variable that resolves to empty; copy-paste of a property name with a trailing space; case mismatch (TRUE vs true).
Related errors
- Invalid tests.bwc.mode value [${mode}]. Must be one of: grad
- Invalid qualifier: ${qualifier}
- build.snapshot was set to [${buildSnapshotSystemProperty}] b
- Sysprop [${property}] must be [true] or [false] but was [${p
- Expected a single original jar, but found: ${oldJarNames}
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/bfd6904753f9e5fe.
Report an issue: GitHub.