elastic/elasticsearch · error · IllegalArgumentException
build.snapshot was set to [${buildSnapshotSystemProperty}] b
Error message
build.snapshot was set to [${buildSnapshotSystemProperty}] but can only be unset or [true|false] What it means
The build.snapshot system property defaults to "true" and is only allowed to be the literal strings "true" or "false". The switch's default branch throws IllegalArgumentException for anything else, including values like yes, 1, True (wrong case), or the empty string.
Source
Thrown at build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/VersionPropertiesLoader.java:61
String qualifier = providers.systemProperty("build.version_qualifier")
.getOrElse("");
if (qualifier.isEmpty() == false) {
if (qualifier.matches("(alpha|beta|rc)\\d+") == false) {
throw new IllegalStateException("Invalid qualifier: " + qualifier);
}
elasticsearch += "-" + qualifier;
}
final String buildSnapshotSystemProperty = providers.systemProperty("build.snapshot")
.getOrElse("true");
switch (buildSnapshotSystemProperty) {
case "true":
elasticsearch += "-SNAPSHOT";
break;
case "false":
// do nothing
break;
default:
throw new IllegalArgumentException(
"build.snapshot was set to [" + buildSnapshotSystemProperty + "] but can only be unset or [true|false]");
}
loadedProps.put("elasticsearch", elasticsearch);
}
}
View on GitHub (pinned to db6a809a66)
Solutions
- Use exactly -Dbuild.snapshot=true or -Dbuild.snapshot=false.
- Leave the property unset if you want the default snapshot behaviour.
- Audit CI scripts and env-to-sysprop mappers for non-canonical boolean encodings.
Example fix
// before ./gradlew build -Dbuild.snapshot=yes // after ./gradlew build -Dbuild.snapshot=false
Defensive patterns
Strategy: validation
Validate before calling
String s = System.getProperty("build.snapshot");
if (s != null && !s.equals("true") && !s.equals("false")) {
throw new GradleException("build.snapshot must be true|false, got: " + s);
} Prevention
- Canonicalise external boolean env vars to true/false before mapping to the sysprop.
- Leave build.snapshot unset to take the default snapshot behaviour.
- Audit CI templates for 1/0/yes/no encodings.
When it happens
Trigger: Running Gradle with -Dbuild.snapshot set to a non-canonical value such as yes, no, 0, 1, TRUE, or an empty string. getOrElse("true") only supplies the default when the property is unset, not when it is blank.
Common situations: A CI template reuses a generic boolean env var that resolves to 1/0 or yes/no; a shell quoting bug passes an empty string; a user assumes case-insensitive parsing.
Related errors
- Invalid qualifier: ${qualifier}
- Elasticsearch version is missing from properties.
- Expected elasticsearch version to be numbers only of the for
- Sysprop [${property}] must be [true] or [false] but was [${p
- Cannot load VersionPropertiesBuildService
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/0b3addbcdaf7443e.
Report an issue: GitHub.