GoogleContainerTools/skaffold · error

failed to unmarshal minikube profile list: %w

Error message

failed to unmarshal minikube profile list: %w

What it means

After successfully running `minikube profile list -o json`, matchServerURL unmarshals the output into the profileList struct. If the JSON doesn't match the expected schema, the error is wrapped as 'failed to unmarshal minikube profile list'. This typically means minikube's output format differs from what this Skaffold version expects.

Source

Thrown at pkg/skaffold/cluster/minikube.go:182

	return v.err.Error()
}

// matchClusterCertPath checks if the cluster certificate for this context is from inside the minikube directory
func matchClusterCertPath(certPath string) bool {
	return certPath != "" && util.IsSubPath(minikubePath(), certPath)
}

// matchServerURL checks if the k8s server url is same as any of the minikube nodes IPs
func matchServerURL(ctx context.Context, server string) (bool, error) {
	cmd, _ := minikubeExec(ctx, "profile", "list", "-o", "json")
	out, err := util.RunCmdOut(ctx, cmd)
	if err != nil {
		return false, fmt.Errorf("getting minikube profiles: %w", err)
	}

	var data profileList
	if err = json.Unmarshal(out, &data); err != nil {
		return false, fmt.Errorf("failed to unmarshal minikube profile list: %w", err)
	}

	serverURL, err := url.Parse(server)
	if err != nil {
		log.Entry(context.TODO()).Tracef("invalid server url: %v", err)
	}

	for _, v := range data.Valid {
		for _, n := range v.Config.Nodes {
			if err == nil && serverURL.Host == fmt.Sprintf("%s:%d", n.IP, n.Port) {
				// TODO: Revisit once https://github.com/kubernetes/minikube/issues/6642 is fixed
				return true, nil
			}
		}
	}
	return false, nil
}

View on GitHub (pinned to a1189de023)

Solutions

  1. Run `minikube profile list -o json` and compare the schema to the version your skaffold expects
  2. Upgrade or downgrade skaffold to match the installed minikube version
  3. Upgrade minikube to the latest version to get the canonical JSON format
  4. Inspect ~/.minikube config for anomalies causing unusual profile list output

Example fix

// before (minikube v0.30 with old output)
skaffold (old) <-> minikube profile list
// after
brew upgrade minikube  # or update skaffold to latest
Defensive patterns

Strategy: validation

Validate before calling

const out = require('child_process').execSync('minikube profile list -o json').toString();
try { const j = JSON.parse(out); if (!Array.isArray(j.invalid) && !j.profiles) throw 0; } catch { console.error('minikube JSON schema mismatch — upgrade minikube or skaffold'); }

Prevention

When it happens

Trigger: json.Unmarshal(out, &data) fails because minikube emits a different profile-list JSON schema than profileList expects — different minikube version, warnings mixed into output, or empty/garbage output.

Common situations: Skaffold built against newer/older minikube JSON schema (field renames like machineName/nodeName); minikube printing deprecation warnings before the JSON; empty output from a failing-but-zero-exit run.

Understand the failure class

Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.

Related errors


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