{"record":{"id":"09ef675c082282d6","repo":"elastic/elasticsearch","slug":"operating-system","errorCode":null,"errorMessage":"Operating system {}","messagePattern":"Operating system (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/toolchain/AbstractCustomJavaToolchainResolver.java","lineNumber":28,"sourceCode":"package org.elasticsearch.gradle.internal.toolchain;\n\nimport org.gradle.jvm.toolchain.JavaToolchainResolver;\nimport org.gradle.jvm.toolchain.JvmVendorSpec;\nimport org.gradle.platform.Architecture;\nimport org.gradle.platform.OperatingSystem;\n\nabstract class AbstractCustomJavaToolchainResolver implements JavaToolchainResolver {\n\n    static String toOsString(OperatingSystem operatingSystem) {\n        return toOsString(operatingSystem, null);\n    }\n\n    static String toOsString(OperatingSystem operatingSystem, JvmVendorSpec v) {\n        return switch (operatingSystem) {\n            case MAC_OS -> (v == null || v.equals(JvmVendorSpec.ADOPTIUM) == false) ? \"macos\" : \"mac\";\n            case LINUX -> \"linux\";\n            case WINDOWS -> \"windows\";\n            default -> throw new UnsupportedOperationException(\"Operating system \" + operatingSystem);\n        };\n    }\n\n    static String toArchString(Architecture architecture) {\n        return switch (architecture) {\n            case X86_64 -> \"x64\";\n            case AARCH64 -> \"aarch64\";\n            case X86 -> \"x86\";\n            default -> throw new UnsupportedOperationException(\"Architecture \" + architecture);\n        };\n    }\n\n    protected static boolean anyVendorOr(JvmVendorSpec givenVendor, JvmVendorSpec expectedVendor) {\n        return givenVendor.matches(\"any\") || givenVendor.equals(expectedVendor);\n    }\n}\n","sourceCodeStart":10,"sourceCodeEnd":45,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/toolchain/AbstractCustomJavaToolchainResolver.java#L10-L45","documentation":"UnsupportedOperationException from the Java toolchain resolver's OS-name mapping. The switch in toOsString() only handles MAC_OS, LINUX, and WINDOWS; any other OperatingSystem enum value falls to default and throws.","triggerScenarios":"Gradle reports an OperatingSystem value outside the three supported ones (e.g. a future Gradle release adding FREE_BSD, SOLARIS, or an UNKNOWN generic type) when resolving a custom JDK toolchain.","commonSituations":"Running the build on an unusual host OS; upgrading Gradle to a version that introduced a new OperatingSystem enum constant; a test faking an unsupported OS.","solutions":["Confirm the host operating system is one of macOS, Linux, or Windows.","If a new OS constant legitimately needs support, add an explicit case branch returning its download-path string.","Pin Gradle to a version whose OperatingSystem enum matches the resolver's expectations."],"exampleFix":"// before\ncase WINDOWS -> \"windows\";\ndefault -> throw new UnsupportedOperationException(\"Operating system \" + operatingSystem);\n\n// after\ncase WINDOWS -> \"windows\";\ncase FREE_BSD -> \"freebsd\";\ndefault -> throw new UnsupportedOperationException(\"Operating system \" + operatingSystem);","handlingStrategy":"validation","validationCode":"Set<OperatingSystem> supported = EnumSet.of(OperatingSystem.MAC_OS, OperatingSystem.LINUX, OperatingSystem.WINDOWS);\nif (!supported.contains(operatingSystem)) {\n    throw new IllegalStateException(\"Unsupported OS for custom toolchain: \" + operatingSystem);\n}","typeGuard":"static boolean isOsSupported(OperatingSystem os) {\n    return os == OperatingSystem.MAC_OS || os == OperatingSystem.LINUX || os == OperatingSystem.WINDOWS;\n}","tryCatchPattern":null,"preventionTips":["Restrict builds to supported operating systems.","Add explicit handling for any new OS before upgrading Gradle.","Document the supported OS matrix in the build README."],"tags":["gradle","toolchain","jdk","build-tooling","platform"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}