GoogleContainerTools/skaffold · error

build target platforms %q do not match platform constraints

Error message

build target platforms %q do not match platform constraints %q defined for artifact %q

What it means

NewResolver returns this error when the resolved build target platforms have an empty intersection with the platform constraints declared on a specific artifact, i.e. the requested targets include no platform the artifact supports. It is a semantic mismatch check (not a parse failure) done after platforms.Intersect(constraints) yields an empty set.

Source

Thrown at pkg/skaffold/platform/resolver.go:110

				platforms = fromClusterNodes
			} else if p := platforms.Intersect(fromClusterNodes); p.IsNotEmpty() {
				platforms = p
			} else {
				log.Entry(ctx).Warnf("build target platforms %q do not match active kubernetes cluster node platforms %q", platforms, fromClusterNodes)
			}
		}
		instrumentation.AddResolvedBuildTargetPlatforms(platforms.String())
		for _, artifact := range pipeline.Build.Artifacts {
			pl := platforms
			constraints, err := Parse(artifact.Platforms)
			if err != nil {
				return r, fmt.Errorf("failed to parse platforms: %w", err)
			}
			if constraints.IsNotEmpty() {
				if pl.IsEmpty() {
					pl = constraints
				} else if pl = pl.Intersect(constraints); pl.IsEmpty() {
					return r, fmt.Errorf("build target platforms %q do not match platform constraints %q defined for artifact %q", platforms, artifact.Platforms, artifact.ImageName)
				}
			}
			if pl.IsMultiPlatform() && opts.DisableMultiPlatformBuild {
				pl = selectOnePlatform(pl)
			}
			r.platformsByImageName[artifact.ImageName] = pl
			log.Entry(ctx).Debugf("platforms selected for artifact %q: %q", artifact.ImageName, pl)
		}
	}
	return r, nil
}

// GetClusterPlatforms returns the platforms for the active kubernetes cluster.
func GetClusterPlatforms(ctx context.Context, kContext string) (Matcher, error) {
	client, err := kubernetesclient.Client(kContext)
	if err != nil {
		return Matcher{}, fmt.Errorf("failed to determine kubernetes cluster node platforms: %w", err)
	}

View on GitHub (pinned to a1189de023)

Solutions

  1. Align the artifact's `platforms` constraints in skaffold.yaml with the requested target platforms (add the missing platform, e.g. linux/amd64).
  2. Change the --platform flag / build.platforms to values that intersect the artifact constraints.
  3. Remove the artifact-level `platforms` restriction so the artifact inherits the global targets.
  4. Read the error message: it echoes both %q platform sets and the artifact ImageName to pinpoint the mismatch.

Example fix

// before (--platform linux/amd64, artifact restricted)
artifacts:
  - image: myapp
    platforms: [linux/arm64]
// after
artifacts:
  - image: myapp
    platforms: [linux/amd64, linux/arm64]
Defensive patterns

Strategy: validation

Validate before calling

const targets = new Set(cliPlatforms ?? pipeline.build?.platforms ?? []);
for (const a of pipeline.build?.artifacts ?? []) {
  if (a.platforms?.length && !a.platforms.some(p => targets.has(p))) {
    throw new Error(`artifact ${a.image}: no overlap between targets ${[...targets]} and constraints ${a.platforms}`);
  }
}

Type guard

function platformsMatch(targets, constraints) {
  return !constraints?.length || constraints.some(c => targets.includes(c));
}

Try / catch

r, err := platform.NewResolver(ctx, opts, pipelines, fromClusterNodes)
if err != nil {
  if strings.Contains(err.Error(), "do not match platform constraints") {
    return fmt.Errorf("fix --platform or artifact constraints; see skaffold.yaml: %w", err)
  }
  return err
}

Prevention

When it happens

Trigger: Running skaffold with --platform linux/amd64 (or build.platforms) while an artifact declares only e.g. linux/arm64, so Intersect returns empty and the error names the target platforms, artifact constraints, and image name.

Common situations: Building on/for the wrong architecture (Apple Silicon host targeting amd64 while artifacts restrict to arm64); CI matrix passing platform values that drifted from artifact constraints; adding a new artifact with restrictive platforms without updating the shared --platform flag.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/ba9a196e37d632e6. Report an issue: GitHub.