GoogleContainerTools/skaffold · error
marshalling yaml: %w
Error message
marshalling yaml: %w
What it means
applyDebuggingTransforms decodes each Kubernetes manifest from YAML, applies debugging transforms to inject the debugging support containers, and re-encodes the object back to YAML. This error is returned when the mutated object cannot be marshalled back into YAML by encodeAsYaml. It indicates the transformed in-memory Kubernetes object (signature, port, env, annotation fields injected by the debugger retriever) failed json/yaml serialization.
Source
Thrown at pkg/skaffold/kubernetes/debugging/transform.go:102
kind = gvk.Kind
if group == "" {
description = fmt.Sprintf("%s/%s", strings.ToLower(kind), name)
} else {
description = fmt.Sprintf("%s.%s/%s", strings.ToLower(kind), group, name)
}
return
}
func applyDebuggingTransforms(l manifest.ManifestList, retriever debug.ConfigurationRetriever, debugHelpersRegistry string) (manifest.ManifestList, error) {
var updated manifest.ManifestList
for _, manifest := range l {
obj, _, err := decodeFromYaml(manifest, nil, nil)
if err != nil {
log.Entry(context.Background()).Debugf("Unable to interpret manifest for debugging: %v\n", err)
} else if transformManifest(obj, retriever, debugHelpersRegistry) {
manifest, err = encodeAsYaml(obj)
if err != nil {
return nil, fmt.Errorf("marshalling yaml: %w", err)
}
if log.IsDebugLevelEnabled() {
log.Entry(context.Background()).Debugln("Applied debugging transform:\n", string(manifest))
}
}
updated = append(updated, manifest)
}
return updated, nil
}
// isPortAvailable returns true if none of the pod's containers specify the given port.
func isPortAvailable(podSpec *v1.PodSpec, port int32) bool {
for _, container := range podSpec.Containers {
for _, portSpec := range container.Ports {
if portSpec.ContainerPort == port {
return false
}View on GitHub (pinned to a1189de023)
Solutions
- Check the wrapped error in the message to identify which field failed to marshal
- Verify the manifest decodes cleanly: run the skaffold debug pipeline on a minimal, standard k8s YAML to isolate the offending resource
- Update the runtime/serialization dependencies (sigs.k8s.io/yaml, k8s.io/apimachinery) to match the k8s library version Skaffold expects
- If only a specific artifact fails, temporarily disable debugging for that artifact (--profile without debug) to confirm the transform is the cause
Example fix
// before: transform injects a value the encoder chokes on; log and skip the transform
manifest, err = encodeAsYaml(obj)
if err != nil {
return nil, fmt.Errorf("marshalling yaml: %w", err)
}
// after: fall back to the untransformed manifest
manifest, err = encodeAsYaml(obj)
if err != nil {
log.Entry(context.Background()).Warnf("skipping debugging transform, encode failed: %v", err)
// keep original manifest
} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-validate the manifest decodes
var raw map[string]interface{}
if err := yaml.Unmarshal([]byte(manifest), &raw); err != nil {
return fmt.Errorf("manifest is not valid YAML, debugging transform would fail later: %w", err)
} Type guard
func isMarshallable(obj runtime.Object) bool {
_, err := json.Marshal(obj)
return err == nil
} Try / catch
updated, err := debug.ApplyDebuggingTransforms(ctx, manifests, retriever)
if err != nil {
if strings.Contains(err.Error(), "marshalling yaml") {
log.Warnf("debug transform failed on a manifest, continuing untransformed: %v", err)
return originalManifests, nil
}
return nil, err
} Prevention
- Test debug profiles against all resource kinds in your manifests before CI
- Keep the k8s io/apimachinery/sigs.k8s.io/yaml versions aligned with the cluster/generator versions
- Validate manifests with `skaffold render --profile=debug` locally before deploying
When it happens
Trigger: An artifact with debugging support enabled is deployed; decodeFromYaml succeeds but transformManifest returns true (transforms were applied) and encodeAsYaml then fails on the mutated object — e.g. the transform injected a value that the k8s runtime serializer cannot marshal.
Common situations: Debugging a container runtarget with an unusual base image where the retrieved debugger config produces non-serializable values; Kubernetes manifest files containing unusual types; a broken/unsupported resource kind that partially decodes and then fails on encode after transformation.
Related errors
- marshalling yaml: %w
- invalid local-registry-hosting ConfigMap
- marshalling configuration: %w
- marshaling new config: %w
- marshaling config: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/ad27012d1fa07de1.
Report an issue: GitHub.