GoogleContainerTools/skaffold · error

applying profile %q: %w

Error message

applying profile %q: %w

What it means

A profile was found, but `applyProfile` failed while merging its overrides (patches, resource/section overrides) into the main skaffold config. The error is wrapped as `applying profile "<name>": %w`, so the inner error names the concrete merge failure, typically an invalid YAML patch or a conflicting override value.

Source

Thrown at pkg/skaffold/schema/profiles.go:58

)

// ApplyProfiles modifies the input skaffold configuration by the application
// of a list of profiles, and returns the list of applied profiles.
func ApplyProfiles(c *latest.SkaffoldConfig, fieldsOverrodeByProfile map[string]configlocations.YAMLOverrideInfo, opts cfg.SkaffoldOptions, namedProfiles []string) ([]string, map[string]configlocations.YAMLOverrideInfo, error) {
	byName := profilesByName(c.Profiles)

	profiles, contextSpecificProfiles, err := activatedProfiles(c.Profiles, opts, namedProfiles)
	if err != nil {
		return nil, nil, fmt.Errorf("finding auto-activated profiles: %w", err)
	}
	for _, name := range profiles {
		profile, present := byName[name]
		if !present {
			return nil, nil, fmt.Errorf("couldn't find profile %s", name)
		}

		if err := applyProfile(c, fieldsOverrodeByProfile, profile); err != nil {
			return nil, nil, fmt.Errorf("applying profile %q: %w", name, err)
		}
	}

	// remove profiles section for run modes where profiles are already merged into the main pipeline
	switch opts.Mode() {
	case cfg.RunModes.Build, cfg.RunModes.Dev, cfg.RunModes.Deploy, cfg.RunModes.Debug, cfg.RunModes.Render, cfg.RunModes.Run, cfg.RunModes.Diagnose, cfg.RunModes.Delete:
		c.Profiles = nil
	}
	return profiles, fieldsOverrodeByProfile, checkKubeContextConsistency(contextSpecificProfiles, opts.KubeContext, c.Deploy.KubeContext)
}

func checkKubeContextConsistency(contextSpecificProfiles []string, cliContext, effectiveContext string) error {
	// cli flag takes precedence
	if cliContext != "" {
		return nil
	}

	kubeConfig, err := kubectx.CurrentConfig()

View on GitHub (pinned to a1189de023)

Solutions

  1. Read the wrapped inner error for the exact patch/override that failed
  2. Validate each patch `path` selector against the current skaffold schema version (`skaffold diagnose --yaml-only`)
  3. Update patch targets after a Skaffold upgrade if the schema changed
  4. Simplify the profile to a minimal patch and add changes back incrementally to isolate the bad patch

Example fix

# before (skaffold.yaml profile patch)
patches:
- path: /build/artifact/0/image
  value: bad
# after
definitions:
patches:
- path: /build/artifacts/0/image
  value: gcr.io/project/img
Defensive patterns

Strategy: try-catch

Validate before calling

func validatePatchTargets(cfg *latest.SkaffoldConfig) error {
    for _, p := range cfg.Profiles {
        for _, patch := range p.Patches {
            if !strings.HasPrefix(patch.Path, "/build") && !strings.HasPrefix(patch.Path, "/deploy") && !strings.HasPrefix(patch.Path, "/portForward") {
                return fmt.Errorf("profile %q patch path %q looks invalid", p.Name, patch.Path)
            }
        }
    }
    return nil
}

Type guard

if err != nil {
    if strings.Contains(err.Error(), "applying profile") {
        name := extractProfileName(err.Error())
        log.Errorf("fix the patches/overrides of profile %q", name)
    }
    return err
}

Prevention

When it happens

Trigger: A profile uses an invalid `patches:` entry (bad JSONPath/opa style, wrong target path) or overrides a field with an incompatible value; applyProfile's merge/patch step returns an error for that profile and ApplyProfiles wraps it with the profile name.

Common situations: Hand-written YAML patches with typos in their `path` selectors; patches that target a field that doesn't exist in the current schema version; upgrading Skaffold so schema fields moved/renamed and old patches no longer match; overriding build/artifacts structures incorrectly.

Related errors


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