{"record":{"id":"5a8a84b37d7aaff7","repo":"GoogleContainerTools/skaffold","slug":"strings-join-errmsgs-n-joined-helm-cleanup-e","errorCode":null,"errorMessage":"strings.Join(errMsgs, \"\\n\") (joined helm cleanup error messages)","messagePattern":"strings\\.Join\\(errMsgs, \"\\\\n\"\\) \\(joined helm cleanup error messages\\)","errorType":"exception","errorClass":"CleanupErr","httpStatus":null,"severity":"error","filePath":"pkg/skaffold/deploy/helm/helm.go","lineNumber":480,"sourceCode":"\t\t}\n\t\targs := []string{}\n\t\tif dryRun {\n\t\t\targs = append(args, \"get\", \"manifest\")\n\t\t} else {\n\t\t\targs = append(args, \"delete\")\n\t\t}\n\t\targs = append(args, releaseName)\n\n\t\tif namespace != \"\" {\n\t\t\targs = append(args, \"--namespace\", namespace)\n\t\t}\n\t\tif err := helm.Exec(ctx, h, out, false, nil, args...); err != nil {\n\t\t\terrMsgs = append(errMsgs, err.Error())\n\t\t}\n\t}\n\n\tif len(errMsgs) != 0 {\n\t\treturn deployerr.CleanupErr(errors.New(strings.Join(errMsgs, \"\\n\")))\n\t}\n\treturn nil\n}\n\nfunc (h *Deployer) HasRunnableHooks() bool {\n\treturn len(h.LegacyHelmDeploy.LifecycleHooks.PreHooks) > 0 || len(h.LegacyHelmDeploy.LifecycleHooks.PostHooks) > 0\n}\n\nfunc (h *Deployer) PreDeployHooks(ctx context.Context, out io.Writer) error {\n\tchildCtx, endTrace := instrumentation.StartTrace(ctx, \"Deploy_PreHooks\")\n\tif err := h.hookRunner.RunPreHooks(childCtx, out); err != nil {\n\t\tendTrace(instrumentation.TraceEndError(err))\n\t\treturn err\n\t}\n\tendTrace()\n\treturn nil\n}\n","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/deploy/helm/helm.go#L462-L498","documentation":"Helm deployer Cleanup runs cleanup commands (e.g. helm delete/hooks) for each release; if any sub-command fails, all messages are collected into errMsgs and joined with newlines, then wrapped via deployerr.CleanupErr. The resulting error text is a multi-line aggregation of every helm failure encountered during cleanup.","triggerScenarios":"Calling Cleanup on a Helm deployer where one or more helm Exec invocations (e.g. 'helm delete' for a release, or hook executions) return non-zero exit codes.","commonSituations":"Release already deleted manually via helm CLI so 'helm delete' fails with 'release: not found'; cluster unreachable or credentials expired; helm hooks failing during uninstall; RBAC restrictions preventing deletion.","solutions":["Read each line of the joined message to see which release/step failed","If the release is already gone, treat it as done or delete the release entry from state; rerun with the release name removed from skaffold.yaml","Re-check cluster connectivity and kubeconfig credentials (kubectl get ns) then retry cleanup","Run the failing helm command manually with --debug to get the root cause"],"exampleFix":"// before (release already deleted, cleanup fails)\nskaffold delete\n// after (skip already-deleted release or clean state)\nhelm list -n mynamespace  # confirm release absent\nskaffold delete --cue-... # or remove stale release from deploy state\n# alternatively: kubectl delete job/servicemanual leftovers manually","handlingStrategy":"try-catch","validationCode":"// before cleanup, check the release exists:\nrel := \"<release>\"\nout, err := exec.Command(\"helm\", \"status\", rel, \"-n\", ns).CombinedOutput()\nreleaseExists := err == nil","typeGuard":null,"tryCatchPattern":"err := d.Cleanup(ctx, out)\nif err != nil {\n    for _, msg := range strings.Split(err.Error(), \"\\n\") {\n        log.Printf(\"helm cleanup failure: %s\", msg)\n        if strings.Contains(msg, \"release: not found\") {\n            log.Println(\"release already removed; treating as cleaned up\")\n        }\n    }\n}","preventionTips":["Verify releases with `helm list` before running skaffold delete/cleanup","Keep kubeconfig credentials valid during long CI jobs","Avoid manual `helm delete` on releases managed by skaffold"],"tags":["helm","kubernetes","cleanup","deploy"],"backgroundTag":"helm-release-cleanup-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"}