{"record":{"id":"0b3addbcdaf7443e","repo":"elastic/elasticsearch","slug":"build-snapshot-was-set-to-buildsnapshotsystempr","errorCode":null,"errorMessage":"build.snapshot was set to [${buildSnapshotSystemProperty}] but can only be unset or [true|false]","messagePattern":"build\\.snapshot was set to \\[(.+?)\\] but can only be unset or \\[true\\|false\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/VersionPropertiesLoader.java","lineNumber":61,"sourceCode":"        String qualifier = providers.systemProperty(\"build.version_qualifier\")\n                .getOrElse(\"\");\n        if (qualifier.isEmpty() == false) {\n            if (qualifier.matches(\"(alpha|beta|rc)\\\\d+\") == false) {\n                throw new IllegalStateException(\"Invalid qualifier: \" + qualifier);\n            }\n            elasticsearch += \"-\" + qualifier;\n        }\n        final String buildSnapshotSystemProperty = providers.systemProperty(\"build.snapshot\")\n                .getOrElse(\"true\");\n        switch (buildSnapshotSystemProperty) {\n            case \"true\":\n                elasticsearch += \"-SNAPSHOT\";\n                break;\n            case \"false\":\n                // do nothing\n                break;\n            default:\n                throw new IllegalArgumentException(\n                        \"build.snapshot was set to [\" + buildSnapshotSystemProperty + \"] but can only be unset or [true|false]\");\n        }\n        loadedProps.put(\"elasticsearch\", elasticsearch);\n    }\n}\n\n","sourceCodeStart":43,"sourceCodeEnd":68,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/VersionPropertiesLoader.java#L43-L68","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n./gradlew build -Dbuild.snapshot=yes\n// after\n./gradlew build -Dbuild.snapshot=false","handlingStrategy":"validation","validationCode":"String s = System.getProperty(\"build.snapshot\");\nif (s != null && !s.equals(\"true\") && !s.equals(\"false\")) {\n    throw new GradleException(\"build.snapshot must be true|false, got: \" + s);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["gradle","build-config","version-properties","validation","system-property"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}