{"record":{"id":"5d2bbd9b5c797e5b","repo":"elastic/elasticsearch","slug":"can-not-determine-architecture-from-architectur","errorCode":null,"errorMessage":"can not determine architecture from [${architecture}]","messagePattern":"can not determine architecture from \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"critical","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/Architecture.java","lineNumber":43,"sourceCode":"\n    Architecture(String classifier, String dockerPlatform, String dockerClassifier, String javaClassifier) {\n        this.classifier = classifier;\n        this.dockerPlatform = dockerPlatform;\n        this.dockerClassifier = dockerClassifier;\n        this.javaClassifier = javaClassifier;\n    }\n\n    @Override\n    public String getName() {\n        return classifier;\n    }\n\n    public static Architecture current() {\n        final String architecture = System.getProperty(\"os.arch\", \"\");\n        return switch (architecture) {\n            case \"amd64\", \"x86_64\" -> X64;\n            case \"aarch64\" -> AARCH64;\n            default -> throw new IllegalArgumentException(\"can not determine architecture from [\" + architecture + \"]\");\n        };\n    }\n\n    /**\n     * Returns the architecture that matches the given Docker platform string (e.g. \"linux/amd64\").\n     *\n     * @param platform the Docker platform string from e.g. {@code docker buildx inspect}\n     * @return the matching architecture, or empty if unknown\n     */\n    public static Optional<Architecture> fromDockerPlatform(String platform) {\n        if (platform == null || platform.isBlank()) {\n            return Optional.empty();\n        }\n        String trimmed = platform.trim();\n        for (Architecture a : values()) {\n            if (a.dockerPlatform.equals(trimmed)) {\n                return Optional.of(a);\n            }","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/Architecture.java#L25-L61","documentation":"Architecture.current maps the JVM's os.arch to either X64 (amd64/x86_64) or AARCH64 (aarch64). Any other architecture — ppc64le, s390x, riscv64, armv7l, or an empty/unknown value — falls through the switch default and throws IllegalArgumentException. This is hit early in build configuration when the distribution plugin resolves the host architecture.","triggerScenarios":"Running the Elasticsearch Gradle build on a JVM whose os.arch is not amd64, x86_64, or aarch64. Most common on POWER, s390x, RISC-V, or 32-bit ARM hosts, or under a misreported cross-arch emulation.","commonSituations":"Building on ppc64le/s390x CI agents; RISC-V or armhf development boards; a JVM reporting an unexpected os.arch string; cross-compilation scenarios that did not override the architecture property.","solutions":["Run on an amd64 or aarch64 host/JVM.","If your arch is equivalent, force it: `-Dos.arch=x86_64` (only when genuinely compatible).","Extend the switch in Architecture.current to map your os.arch and contribute the change.","For distribution tasks, set the distribution's architecture explicitly via setArchitecture rather than relying on current()."],"exampleFix":"// before: build on ppc64le throws\n./gradlew :distribution:archives:linux-tar:assemble\n// after: build under a compatible arch or override\njava -Dos.arch=x86_64 -jar gradle-wrapper.jar :distribution:archives:linux-tar:assemble  # only if truly compatible","handlingStrategy":"validation","validationCode":"static Optional<Architecture> safeCurrent() {\n    String arch = System.getProperty(\"os.arch\", \"\");\n    return switch (arch) {\n        case \"amd64\", \"x86_64\" -> Optional.of(Architecture.X64);\n        case \"aarch64\" -> Optional.of(Architecture.AARCH64);\n        default -> Optional.empty();\n    };\n}\n// then: safeCurrent().orElseThrow(() -> new IllegalStateException(\"Unsupported os.arch: \" + System.getProperty(\"os.arch\")))","typeGuard":"static boolean isSupportedArch(String osArch) {\n    return \"amd64\".equals(osArch) || \"x86_64\".equals(osArch) || \"aarch64\".equals(osArch);\n}","tryCatchPattern":null,"preventionTips":["Run Elasticsearch builds on amd64 or aarch64 hosts.","If your arch is binary-compatible, override -Dos.arch explicitly and document why.","Set the distribution's architecture via setArchitecture rather than relying on current()."],"tags":["gradle","architecture","platform","validation"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}