{"record":{"id":"d7a1dda29efee73d","repo":"docker/cli","slug":"invalid-platform-w","errorCode":null,"errorMessage":"invalid platform: %w","messagePattern":"invalid platform: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/image/history.go","lineNumber":64,"sourceCode":"\tflags := cmd.Flags()\n\n\tflags.BoolVarP(&opts.human, \"human\", \"H\", true, \"Print sizes and dates in human readable format\")\n\tflags.BoolVarP(&opts.quiet, \"quiet\", \"q\", false, \"Only show image IDs\")\n\tflags.BoolVar(&opts.noTrunc, \"no-trunc\", false, \"Don't truncate output\")\n\tflags.StringVar(&opts.format, \"format\", \"\", flagsHelper.FormatHelp)\n\tflags.StringVar(&opts.platform, \"platform\", \"\", `Show history for the given platform. Formatted as \"os[/arch[/variant]]\" (e.g., \"linux/amd64\")`)\n\t_ = flags.SetAnnotation(\"platform\", \"version\", []string{\"1.48\"})\n\n\t_ = cmd.RegisterFlagCompletionFunc(\"platform\", completion.Platforms())\n\treturn cmd\n}\n\nfunc runHistory(ctx context.Context, dockerCli command.Cli, opts historyOptions) error {\n\tvar options []client.ImageHistoryOption\n\tif opts.platform != \"\" {\n\t\tp, err := platforms.Parse(opts.platform)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid platform: %w\", err)\n\t\t}\n\t\toptions = append(options, client.ImageHistoryWithPlatform(p))\n\t}\n\n\thistory, err := dockerCli.Client().ImageHistory(ctx, opts.image, options...)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tformat := opts.format\n\tif len(format) == 0 {\n\t\tformat = formatter.TableFormatKey\n\t}\n\n\thistoryCtx := formatter.Context{\n\t\tOutput: dockerCli.Out(),\n\t\tFormat: newHistoryFormat(format, opts.quiet, opts.human),\n\t\tTrunc:  !opts.noTrunc,","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/image/history.go#L46-L82","documentation":"Returned by runHistory (history.go:64) when platforms.Parse rejects the --platform flag value for 'docker image history'. The platform string must follow the 'os[/arch[/variant]]' form (e.g., 'linux/amd64'). Parse fails on empty OS, unknown component separators, or malformed tokens. This is the same validator used across build/load/save.","triggerScenarios":"Running 'docker image history --platform <bad> <image>' where <bad> is empty-ish, has extra slashes, a missing OS, or non-identifier characters. Examples: '--platform amd64' (missing OS), '--platform linux/extra/v8/wrong' (too many parts), '--platform /amd64' (empty OS).","commonSituations":"Forgetting the OS and passing only the architecture ('--platform amd64'); using full OCI image platform strings with unexpected fields; copy-pasting a platform string from a multi-arch manifest that includes OS features/variants in an unsupported order; trailing slashes.","solutions":["Use the canonical form 'os/arch[/variant]': '--platform linux/amd64'.","If you only know the architecture, prepend the OS: 'linux/' + arch.","List supported platforms with 'docker image inspect --format '{{.Os}}/{{.Architecture}}' <image>'.","Drop --platform entirely to let the daemon pick the default."],"exampleFix":"# before\ndocker image history --platform amd64 nginx\n# after\ndocker image history --platform linux/amd64 nginx","handlingStrategy":"validation","validationCode":"// Validate a platform string before passing it to --platform.\nimport \"github.com/containerd/platforms\"\n\nfunc validatePlatform(p string) error {\n\t_, err := platforms.Parse(p)\n\treturn err\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.Execute(); err != nil {\n\tif strings.Contains(err.Error(), \"invalid platform\") {\n\t\t// re-prompt for a correctly formatted os/arch[/variant] string\n\t}\n}","preventionTips":["Always include the OS: 'linux/amd64', not just 'amd64'.","Use 'docker image inspect' to discover the image's actual platform components.","Omit --platform to accept the daemon default."],"tags":["image","history","platform","validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}