{"record":{"id":"025b241597ee1ce9","repo":"docker/cli","slug":"invalid-platform-w-025b24","errorCode":null,"errorMessage":"invalid platform: %w","messagePattern":"invalid platform: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/image/load.go","lineNumber":86,"sourceCode":"\t\t// depleting the standby list un-necessarily. On Linux, this equates to a regular os.Open.\n\t\tfile, err := sequential.Open(opts.input)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer func() { _ = file.Close() }()\n\t\tinput = file\n\t}\n\n\tvar options []client.ImageLoadOption\n\tif opts.quiet || !dockerCli.Out().IsTerminal() {\n\t\toptions = append(options, client.ImageLoadWithQuiet(true))\n\t}\n\n\tplatformList := []ocispec.Platform{}\n\tfor _, p := range opts.platform {\n\t\tpp, err := platforms.Parse(p)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid platform: %w\", err)\n\t\t}\n\t\tplatformList = append(platformList, pp)\n\t}\n\tif len(platformList) > 0 {\n\t\toptions = append(options, client.ImageLoadWithPlatforms(platformList...))\n\t}\n\n\tres, err := dockerCli.Client().ImageLoad(ctx, input, options...)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() { _ = res.Close() }()\n\n\treturn jsonstream.Display(ctx, res, dockerCli.Out())\n}\n","sourceCodeStart":68,"sourceCodeEnd":102,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/image/load.go#L68-L102","documentation":"Returned by runLoad (load.go:86) when platforms.Parse rejects one of the --platform values for 'docker image load'. The flag accepts a comma-separated list (via StringSliceVar) and each entry is parsed independently; the first malformed entry aborts the load. Valid form is 'os[/arch[/variant]]'.","triggerScenarios":"Running 'docker image load --platform <bad>[,<bad>]' where any element is malformed: missing OS, too many slash-separated parts, empty tokens, or non-identifier characters. Because the flag is a slice, a single bad entry among several fails the whole invocation.","commonSituations":"Passing '--platform amd64' (arch only, no OS); mixing a correct 'linux/amd64' with a malformed 'x86'; copy-pasting a manifest platform string with extra fields; trailing commas producing an empty element.","solutions":["Format each platform as 'os/arch[/variant]': '--platform linux/amd64,linux/arm64'.","Remove any malformed entries from the comma-separated list.","Validate each token against the image's manifest before loading.","Omit --platform to load all platforms."],"exampleFix":"# before\ndocker image load --platform amd64,arm64 -i image.tar\n# after\ndocker image load --platform linux/amd64,linux/arm64 -i image.tar","handlingStrategy":"validation","validationCode":"// Validate each platform in a comma-separated --platform list.\nfunc validatePlatforms(list []string) error {\n\tfor _, p := range list {\n\t\tif _, err := platforms.Parse(p); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid platform %q: %w\", p, err)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.Execute(); err != nil {\n\tif strings.Contains(err.Error(), \"invalid platform\") {\n\t\t// one of the comma-separated platforms is malformed; correct the list\n\t}\n}","preventionTips":["Format every element as os/arch[/variant].","Avoid trailing commas that produce empty tokens.","Validate the list programmatically before running the command."],"tags":["image","load","platform","validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}