{"record":{"id":"f1417d4e7eab3f30","repo":"GoogleContainerTools/skaffold","slug":"failed-to-load-manifest","errorCode":null,"errorMessage":"failed to load manifest","messagePattern":"failed to load manifest","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/hooks/render.go","lineNumber":80,"sourceCode":"}\n\nfunc (r renderRunner) GetConfigName() string {\n\treturn r.configName\n}\n\nfunc (r renderRunner) RunPreHooks(ctx context.Context, out io.Writer) error {\n\treturn r.run(ctx, out, r.PreHooks, phases.PreRender)\n}\n\nfunc (r renderRunner) RunPostHooks(ctx context.Context, list manifest.ManifestList, out io.Writer) (manifest.ManifestList, error) {\n\tlogWriter := log.GetWriter()\n\n\tif len(r.PostHooks) > 0 {\n\t\toutput.Default.Fprintln(logWriter, fmt.Sprintf(\"Starting %s hooks...\", phases.PostRender))\n\t}\n\tupdated, err := manifest.Load(list.Reader())\n\tif err != nil {\n\t\treturn manifest.ManifestList{}, fmt.Errorf(\"failed to load manifest\")\n\t}\n\tenv := r.getEnv()\n\tfor _, h := range r.PostHooks {\n\t\tif h.HostHook != nil {\n\t\t\thook := hostHook{latest.HostHook{\n\t\t\t\tCommand: h.HostHook.Command,\n\t\t\t\tOS:      h.HostHook.OS,\n\t\t\t\tDir:     h.HostHook.Dir,\n\t\t\t}, env}\n\t\t\tvar b bytes.Buffer\n\t\t\tif h.HostHook.WithChange {\n\t\t\t\tif err := hook.run(ctx, updated.Reader(), &b); err != nil {\n\t\t\t\t\tif errors.Is(err, &Skip{}) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\treturn manifest.ManifestList{}, err\n\t\t\t\t}\n\t\t\t\tif b.Len() == 0 {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/hooks/render.go#L62-L98","documentation":"RunPostHooks for the render phase loads the rendered manifest list with manifest.Load(list.Reader()) before applying post-render hooks. If loading/parsing the manifests fails, it returns a bare 'failed to load manifest' (note: unlike most errors here, the underlying cause is not wrapped).","triggerScenarios":"Calling RunPostHooks with a reader (list.Reader()) whose content is empty, truncated, or not valid multi-document YAML/Kubernetes manifests — so manifest.Load cannot parse it.","commonSituations":"Renderer produced empty output (helm/kustomize failed silently or wrote nothing); manifests corrupted by a buggy previous post-render hook writing garbage to stdout; YAML syntax errors in the rendered output; binary or non-UTF8 data on the stream.","solutions":["Run the renderer alone (skaffold render) and inspect the output YAML for emptiness or syntax errors","Check stdout pollution: earlier hooks or scripts must not print non-manifest data to stdout","Validate the rendered YAML with 'kubectl apply --dry-run=client -f -' to find parse errors","Fix the underlying renderer config (helm/kustomize) that produced invalid output"],"exampleFix":"// before: hook echoes noise to stdout, corrupting the manifest stream\npostRender:\n  hostHooks:\n    - command: [\"echo\", \"rendering done...\"]\n// after: send diagnostics to stderr\npostRender:\n  hostHooks:\n    - command: [\"/bin/sh\", \"-c\", \"echo rendering done... 1>&2\"]","handlingStrategy":"validation","validationCode":"data, err := io.ReadAll(list.Reader())\nif err != nil { return err }\nif len(bytes.TrimSpace(data)) == 0 {\n    return errors.New(\"renderer produced empty manifest output\")\n}\nif err := yaml.Unmarshal(data, &map[string]any{}); err != nil {\n    return fmt.Errorf(\"manifests not valid YAML: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"updated, err := r.RunPostHooks(ctx, out, list)\nif err != nil && err.Error() == \"failed to load manifest\" {\n    // cause is unwrapped: dump the stream to debug\n    log.Printf(\"dumping manifest stream for diagnosis:\\n%s\", rawOutput)\n    return err\n}","preventionTips":["Keep post-render hooks writing only to stderr, never stdout","Run 'skaffold render' and validate output with kubectl dry-run before hooking","Fail fast in CI when the renderer emits empty output","Pin helm/kustomize versions to avoid silent rendering changes"],"tags":["manifest","render","yaml","hooks"],"backgroundTag":"manifest-load-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}