{"record":{"id":"e677cf31a219cbdb","repo":"spring-projects/spring-boot","slug":"value-must-be-in-the-form-os-architecture","errorCode":null,"errorMessage":"'value' [{}] must be in the form 'os[/architecture[/variant]]'","messagePattern":"'value' \\[(.+?)\\] must be in the form 'os\\[/architecture\\[/variant\\]\\]'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/ImagePlatform.java","lineNumber":93,"sourceCode":"\t\t\tbuilder.append(\"/\").append(this.variant);\n\t\t}\n\t\treturn builder.toString();\n\t}\n\n\t/**\n\t * Create a new {@link ImagePlatform} from the given value in the form\n\t * {@code os[/architecture[/variant]]}.\n\t * @param value the value to parse\n\t * @return an {@link ImagePlatform} instance\n\t */\n\tpublic static ImagePlatform of(String value) {\n\t\tAssert.hasText(value, \"'value' must not be empty\");\n\t\tString[] split = value.split(\"/+\");\n\t\treturn switch (split.length) {\n\t\t\tcase 1 -> new ImagePlatform(split[0], null, null);\n\t\t\tcase 2 -> new ImagePlatform(split[0], split[1], null);\n\t\t\tcase 3 -> new ImagePlatform(split[0], split[1], split[2]);\n\t\t\tdefault -> throw new IllegalArgumentException(\n\t\t\t\t\t\"'value' [\" + value + \"] must be in the form 'os[/architecture[/variant]]'\");\n\t\t};\n\t}\n\n\t/**\n\t * Create a new {@link ImagePlatform} matching the platform information from the\n\t * provided {@link Image}.\n\t * @param image the image to get platform information from\n\t * @return an {@link ImagePlatform} instance\n\t */\n\tpublic static ImagePlatform from(Image image) {\n\t\treturn new ImagePlatform(image.getOs(), image.getArchitecture(), image.getVariant());\n\t}\n\n\t/**\n\t * Return a JSON-encoded representation of this platform.\n\t * @return the JSON string\n\t */","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/270dfe353fb830fd69b823a8a859287ff103854b/buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/ImagePlatform.java#L75-L111","documentation":"ImagePlatform.of(value) parses a string of form os[/architecture[/variant]] by splitting on one-or-more slashes ('/+'). If the resulting array has fewer than 1 or more than 3 segments, the value is malformed and the method throws IllegalArgumentException.","triggerScenarios":"Setting BP_IMAGE_PLATFORM (or related configuration) to a value with too many slash segments, e.g. 'linux/amd64/v2/extra'.","commonSituations":"Copy-pasting a full OCI platform string with extra fields; trailing or duplicated slashes producing unexpected segments; typos in platform spec.","solutions":["Use exactly 'os', 'os/arch', or 'os/arch/variant'","Validate by splitting on '/' and asserting 1-3 segments before calling of()","Strip trailing slashes and surrounding whitespace before parsing"],"exampleFix":"// before\nImagePlatform.of(\"linux/amd64/v2/extra\")\n// after\nImagePlatform.of(\"linux/amd64/v2\")","handlingStrategy":"validation","validationCode":"String[] parts = value.split(\"/+\");\nif (parts.length < 1 || parts.length > 3) {\n    throw new IllegalArgumentException(\"Platform must be os[/arch[/variant]]: \" + value);\n}\nImagePlatform.of(value);","typeGuard":"static boolean isValidPlatformSpec(String v) { return v != null && v.trim().matches(\"[^/]+(/[^/]+(/[^/]+)?)?\"); }","tryCatchPattern":"try { ImagePlatform.of(value); } catch (IllegalArgumentException ex) { log.error(\"Platform spec must be os[/arch[/variant]]: {}\", value); throw ex; }","preventionTips":["Use exactly 'os', 'os/arch', or 'os/arch/variant'","Strip trailing slashes and whitespace before parsing","Validate the split length before calling of()"],"tags":["parsing","configuration","buildpack"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}