{"record":{"id":"151cead5b4606b98","repo":"elastic/elasticsearch","slug":"invalid-tests-bwc-mode-value-mode-must-be-on","errorCode":null,"errorMessage":"Invalid tests.bwc.mode value [${mode}]. Must be one of: gradle, dra, auto","messagePattern":"Invalid tests\\.bwc\\.mode value \\[(.+?)\\]\\. Must be one of: gradle, dra, auto","errorType":"validation","errorClass":"InvalidUserDataException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPlugin.java","lineNumber":673,"sourceCode":"                    if (expectedOutputFile.exists() == false) {\n                        Path relativeOutputPath = rootDir.toPath().relativize(expectedOutputFile.toPath());\n                        throw new InvalidUserDataException(\n                            \"Downloading %s from DRA didn't produce expected artifact [%s].\".formatted(bwcVersion.get(), relativeOutputPath)\n                        );\n                    }\n                });\n            });\n        }\n        bwcTaskProvider.configure(t -> t.dependsOn(bwcTaskName));\n    }\n\n    /**\n     * Validates the {@code tests.bwc.mode} value, throwing {@link InvalidUserDataException} for\n     * unrecognised values so users get a clear error message rather than a silent no-op.\n     */\n    static void validateBwcMode(String mode) {\n        if (Set.of(\"gradle\", \"dra\", \"auto\").contains(mode) == false) {\n            throw new InvalidUserDataException(\"Invalid tests.bwc.mode value [\" + mode + \"]. Must be one of: gradle, dra, auto\");\n        }\n    }\n\n    /**\n     * Returns the human-readable log message to emit when the gradle source-build fallback is\n     * taken.  The message varies by mode (to explain <em>why</em> the fallback occurred) and by\n     * artifact type (distribution archive vs. Maven JAR).\n     *\n     * <p>Extracted as a package-private static method so it can be exercised by unit tests without\n     * standing up a full Gradle project.\n     */\n    static String buildFallbackMessage(String bwcMode, boolean isDistributionArchive, String bwcVersion, String projectName) {\n        String draUnavailable = \" — tests.bwc.mode=dra but no DRA snapshot was available\"\n            + \" (endpoint unreachable or no build for this branch yet); falling back to source build\";\n        if (isDistributionArchive) {\n            return switch (bwcMode) {\n                case \"dra\" -> \"BWC [\" + bwcVersion + \"]: building distribution [\" + projectName + \"] from source\" + draUnavailable;\n                case \"auto\" -> \"BWC [\"","sourceCodeStart":655,"sourceCodeEnd":691,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPlugin.java#L655-L691","documentation":"Thrown as InvalidUserDataException by validateBwcMode() when the tests.bwc.mode system property is not one of 'gradle', 'dra', or 'auto'. The validator runs at configuration time to give users a clear, immediate error rather than a silent no-op or cryptic downstream failure. 'gradle' forces source builds, 'dra' forces DRA downloads, 'auto' tries DRA then falls back.","triggerScenarios":"validateBwcMode(mode) at line 671 checks Set.of(\"gradle\", \"dra\", \"auto\").contains(mode). Any other value — 'source', 'snapshot', empty string, typo like 'auto ' (trailing space), or 'DRA' (wrong case) — throws immediately.","commonSituations":"Developer guesses the property value (-Dtests.bwc.mode=source); CI config has a typo or stale value; copy-paste from docs with wrong case; trailing whitespace from shell expansion.","solutions":["Use exactly one of: gradle, dra, auto (lowercase). Example: -Dtests.bwc.mode=auto.","If unsure which to use, pick 'auto' — it tries DRA first and falls back to gradle.","Check for trailing spaces or quotes in the shell variable feeding the property."],"exampleFix":"# before\n./gradlew bwcTest -Dtests.bwc.mode=source\n\n# after\n./gradlew bwcTest -Dtests.bwc.mode=gradle","handlingStrategy":"validation","validationCode":"String mode = System.getProperty(\"tests.bwc.mode\", \"auto\");\nif (Set.of(\"gradle\", \"dra\", \"auto\").contains(mode) == false) {\n    throw new IllegalArgumentException(\"Invalid tests.bwc.mode: \" + mode + \". Use gradle, dra, or auto.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only lowercase gradle, dra, or auto for tests.bwc.mode.","Default to auto when unsure — it handles fallback gracefully.","Validate the property in CI scripts before invoking Gradle.","Document the allowed values wherever BWC mode is referenced."],"tags":["bwc","system-property","validation","gradle"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}