GoogleContainerTools/skaffold · error
failed to parse platforms: %w
Error message
failed to parse platforms: %w
What it means
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.
Source
Thrown at pkg/skaffold/platform/resolver.go:65
CheckClusterNodePlatforms bool
}
func (r Resolver) GetPlatforms(imageName string) Matcher {
if r.platformsByImageName == nil {
return Matcher{}
}
return r.platformsByImageName[imageName]
}
func NewResolver(ctx context.Context, pipelines []latest.Pipeline, opts ResolverOpts) (Resolver, error) {
r := Resolver{}
r.platformsByImageName = make(map[string]Matcher)
var fromCli, fromClusterNodes Matcher
var err error
fromCli, err = Parse(opts.CliPlatformsSelection)
if err != nil {
return r, fmt.Errorf("failed to parse platforms: %w", err)
}
log.Entry(ctx).Debugf("CLI platforms provided: %q", fromCli)
instrumentation.AddCliBuildTargetPlatforms(fromCli.String())
if opts.CheckClusterNodePlatforms {
fromClusterNodes, err = getClusterPlatforms(ctx, opts.KubeContext)
if err != nil {
log.Entry(ctx).Debugf("failed to get cluster node details: %v", err)
log.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")
}
log.Entry(ctx).Debugf("platforms detected from active kubernetes cluster nodes: %q", fromClusterNodes)
instrumentation.AddDeployNodePlatforms(fromClusterNodes.String())
} else {
log.Entry(ctx).Debugln("platform detection from active kubernetes cluster is not enabled")
}
for _, pipeline := range pipelines {
platforms := fromCliView on GitHub (pinned to a1189de023)
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
Example fix
// before skaffold build --platform linux/ // after skaffold build --platform linux/amd64
Defensive patterns
Strategy: validation
Validate before calling
function validPlatformSelection(sel) {
if (typeof sel !== "string" || sel.length === 0) return false;
return sel.split(",").every(p => {
const [os, arch] = p.split("/");
return os && arch && os.length > 0 && arch.length > 0;
});
}
if (!validPlatformSelection(cliPlatforms)) throw new Error("invalid --platform value"); Type guard
function isValidPlatformToken(p) {
return /^[a-z0-9]+\/[a-z0-9]+$/.test(p);
} Try / catch
try {
resolver, err := platform.NewResolver(opts)
if err != nil {
if strings.Contains(err.Error(), "failed to parse platforms") {
return fmt.Errorf("bad --platform value %q: %w", opts.CliPlatformsSelection, err)
}
return err
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- `apply` requires at least one manifest argument
- `exec` requires exactly one action to execute
- `config-dependencies add` requires exactly one file path arg
- `jobManifestPaths modify` requires exactly one manifest file
- `inspect namespaces list` requires exactly one manifest file
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/0e19d296950570aa.
Report an issue: GitHub.