{"record":{"id":"4d783ae3a6cd9249","repo":"GoogleContainerTools/jib","slug":"platform-must-be-of-form-os-architecture","errorCode":null,"errorMessage":"Platform must be of form os/architecture.","messagePattern":"Platform must be of form os/architecture\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/PlatformParameters.java","lineNumber":34,"sourceCode":"\npackage com.google.cloud.tools.jib.gradle;\n\nimport com.google.cloud.tools.jib.plugins.common.RawConfiguration.PlatformConfiguration;\nimport java.util.Objects;\nimport java.util.Optional;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\nimport javax.annotation.Nullable;\nimport org.gradle.api.tasks.Input;\nimport org.gradle.api.tasks.Internal;\n\n/** Configuration of a platform. */\npublic class PlatformParameters implements PlatformConfiguration {\n\n  static PlatformParameters of(String osArchitecture) {\n    Matcher matcher = Pattern.compile(\"([^/ ]+)/([^/ ]+)\").matcher(osArchitecture);\n    if (!matcher.matches()) {\n      throw new IllegalArgumentException(\"Platform must be of form os/architecture.\");\n    }\n    PlatformParameters platformParameters = new PlatformParameters();\n    platformParameters.os = matcher.group(1);\n    platformParameters.architecture = matcher.group(2);\n    return platformParameters;\n  }\n\n  @Nullable private String os;\n  @Nullable private String architecture;\n\n  @Input\n  @Nullable\n  public String getOs() {\n    return os;\n  }\n\n  @Internal\n  @Override","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/PlatformParameters.java#L16-L52","documentation":"PlatformParameters.of parses an 'os/architecture' string into platform config for multi-image builds. The input must match the regex ([^/ ]+)/([^/ ]+) — exactly one non-space segment, a slash, and another non-space segment — otherwise it throws IllegalArgumentException that the platform must be of the form os/architecture.","triggerScenarios":"Constructing platform parameters programmatically (e.g. from a string like 'linux' with no slash, 'linux/amd64/extra', or strings containing spaces like 'linux amd64') — PlatformParameters.of is called with an osArchitecture string that fails the pattern match.","commonSituations":"Generating jib platforms from external config/CLI flags where the separator is ',' or '-' instead of '/'; including spaces from CSV parsing; passing a full platform triple instead of os/arch pair.","solutions":["Format the value as exactly '<os>/<architecture>', e.g. 'linux/amd64'","Strip surrounding spaces and ensure neither segment contains spaces","Split on only the first slash if the input may contain extra segments","Validate the string against ([^/ ]+)/([^/ ]+) before calling of()"],"exampleFix":"// before\nPlatformParameters.of(\"linux amd64\")\n// after\nPlatformParameters.of(\"linux/amd64\")","handlingStrategy":"validation","validationCode":"static boolean isValidPlatform(String s) {\n  s ==~ /[^\\/ ]+\\/[^\\/ ]+/  // e.g. linux/amd64\n}","typeGuard":"static String normalizePlatform(String s) {\n  def parts = s?.trim()?.split('/')\n  (parts?.length == 2 && parts.every { it && !it.contains(' ') }) ? s : null\n}","tryCatchPattern":"try {\n  def p = PlatformParameters.of(osArch)\n} catch (IllegalArgumentException e) {\n  if (e.message.contains('of form os/architecture')) {\n    throw new IllegalArgumentException(\"'${osArch}' must be '<os>/<arch>', e.g. linux/amd64\")\n  } else { throw e }\n}","preventionTips":["Use '/' as the platform separator everywhere (CLI, config generators, CSVs)","Reject platform strings containing spaces during config parsing","Validate with the regex ([^/ ]+)/([^/ ]+) before calling of()","Use a fixed allowlist of platforms (linux/amd64, linux/arm64) in scripts"],"tags":["jib","gradle","platform","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}