{"id":"ceb7a90cbb3ef14f","repo":"docker/cli","slug":"invalid-platform-w-ceb7a9","errorCode":null,"errorMessage":"invalid platform: %w","messagePattern":"invalid platform: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/image/save.go","lineNumber":62,"sourceCode":"\tflags := cmd.Flags()\n\n\tflags.StringVarP(&opts.output, \"output\", \"o\", \"\", \"Write to a file, instead of STDOUT\")\n\tflags.StringSliceVar(&opts.platform, \"platform\", []string{}, `Save only the given platform(s). Formatted as a comma-separated list of \"os[/arch[/variant]]\" (e.g., \"linux/amd64,linux/arm64/v8\")`)\n\t_ = flags.SetAnnotation(\"platform\", \"version\", []string{\"1.48\"})\n\n\t_ = cmd.RegisterFlagCompletionFunc(\"platform\", completion.Platforms())\n\treturn cmd\n}\n\n// runSave performs a save against the engine based on the specified options\nfunc runSave(ctx context.Context, dockerCLI command.Cli, opts saveOptions) error {\n\tvar options []client.ImageSaveOption\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.ImageSaveWithPlatforms(platformList...))\n\t}\n\n\tvar output io.Writer\n\tif opts.output == \"\" {\n\t\tif dockerCLI.Out().IsTerminal() {\n\t\t\treturn errors.New(\"cowardly refusing to save to a terminal. Use the -o flag or redirect\")\n\t\t}\n\t\toutput = dockerCLI.Out()\n\t} else {\n\t\twriter, err := atomicwriter.New(opts.output, 0o600)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to save image: %w\", err)\n\t\t}","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/image/save.go#L44-L80","documentation":"Error \"invalid platform: %w\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/command/image/save.go:62 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}