{"record":{"id":"0e19d296950570aa","repo":"GoogleContainerTools/skaffold","slug":"failed-to-parse-platforms-w","errorCode":null,"errorMessage":"failed to parse platforms: %w","messagePattern":"failed to parse platforms: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/platform/resolver.go","lineNumber":65,"sourceCode":"\tCheckClusterNodePlatforms bool\n}\n\nfunc (r Resolver) GetPlatforms(imageName string) Matcher {\n\tif r.platformsByImageName == nil {\n\t\treturn Matcher{}\n\t}\n\treturn r.platformsByImageName[imageName]\n}\n\nfunc NewResolver(ctx context.Context, pipelines []latest.Pipeline, opts ResolverOpts) (Resolver, error) {\n\tr := Resolver{}\n\tr.platformsByImageName = make(map[string]Matcher)\n\n\tvar fromCli, fromClusterNodes Matcher\n\tvar err error\n\tfromCli, err = Parse(opts.CliPlatformsSelection)\n\tif err != nil {\n\t\treturn r, fmt.Errorf(\"failed to parse platforms: %w\", err)\n\t}\n\tlog.Entry(ctx).Debugf(\"CLI platforms provided: %q\", fromCli)\n\tinstrumentation.AddCliBuildTargetPlatforms(fromCli.String())\n\n\tif opts.CheckClusterNodePlatforms {\n\t\tfromClusterNodes, err = getClusterPlatforms(ctx, opts.KubeContext)\n\t\tif err != nil {\n\t\t\tlog.Entry(ctx).Debugf(\"failed to get cluster node details: %v\", err)\n\t\t\tlog.Entry(ctx).Warnln(\"failed to detect active kubernetes cluster node platform. Specify the correct build platform in the `skaffold.yaml` file or using the `--platform` flag\")\n\t\t}\n\t\tlog.Entry(ctx).Debugf(\"platforms detected from active kubernetes cluster nodes: %q\", fromClusterNodes)\n\t\tinstrumentation.AddDeployNodePlatforms(fromClusterNodes.String())\n\t} else {\n\t\tlog.Entry(ctx).Debugln(\"platform detection from active kubernetes cluster is not enabled\")\n\t}\n\n\tfor _, pipeline := range pipelines {\n\t\tplatforms := fromCli","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/platform/resolver.go#L47-L83","documentation":"NewResolver parses the platform selection supplied via CLI options (opts.CliPlatformsSelection) using Parse; any parse failure is wrapped in this error. It means the --platform value (or equivalent option) is syntactically invalid, so no platform resolver can be constructed. The wrapped error names the offending token.","triggerScenarios":"NewResolver (or NewForConfig) is called with opts.CliPlatformsSelection that Parse cannot parse: empty but set, malformed like linux/ or /amd64, invalid tokens like linux/x86_64, or a bad multi-platform list format.","commonSituations":"Passing --platform with a trailing slash or empty component; comma vs. space confusion in multi-platform values; using Docker-style names (macos) or arch aliases (x86_64) not accepted by the parser.","solutions":["Fix the --platform syntax to os/arch form, e.g. linux/amd64 or linux/amd64,darwin/arm64","Remove empty components (no linux/ or /amd64) and unknown OS/arch tokens","Run with a known-good value like --platform linux/amd64 to confirm the flag wiring, then adjust","If platforms should come from the cluster instead, omit the CLI selection rather than passing an invalid one"],"exampleFix":"// before\nskaffold build --platform linux/\n// after\nskaffold build --platform linux/amd64","handlingStrategy":"validation","validationCode":"function validPlatformSelection(sel) {\n  if (typeof sel !== \"string\" || sel.length === 0) return false;\n  return sel.split(\",\").every(p => {\n    const [os, arch] = p.split(\"/\");\n    return os && arch && os.length > 0 && arch.length > 0;\n  });\n}\nif (!validPlatformSelection(cliPlatforms)) throw new Error(\"invalid --platform value\");","typeGuard":"function isValidPlatformToken(p) {\n  return /^[a-z0-9]+\\/[a-z0-9]+$/.test(p);\n}","tryCatchPattern":"try {\n  resolver, err := platform.NewResolver(opts)\n  if err != nil {\n    if strings.Contains(err.Error(), \"failed to parse platforms\") {\n      return fmt.Errorf(\"bad --platform value %q: %w\", opts.CliPlatformsSelection, err)\n    }\n    return err\n  }\n}","preventionTips":["Always pass platform selections as os/arch pairs separated by commas: linux/amd64,darwin/arm64","Reject empty components (linux/ or /amd64) at the CLI/pipeline input boundary","Run a dry run with --platform linux/amd64 to verify flag wiring before production builds","Share one platform-validation helper across scripts that invoke skaffold"],"tags":["platform","cli","parsing"],"backgroundTag":"platform-string-parse-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}