{"record":{"id":"9dfa605afedad4d3","repo":"microsoft/aspire","slug":"helm-uninstall-for-chart-chart-name-failed-with-exit-code","errorCode":null,"errorMessage":"helm uninstall for chart '{chart.Name}' failed with exit code {exitCode}","messagePattern":"helm uninstall for chart '(.+?)' failed with exit code (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Kubernetes/KubernetesHelmChartExtensions.cs","lineNumber":456,"sourceCode":"\n        var exitCode = await helmRunner.RunAsync(\n            arguments.ToString(),\n            onOutputData: output => logger.LogDebug(\"helm (stdout): {Output}\", output),\n            onErrorData: error =>\n            {\n                stderrBuilder.AppendLine(error);\n                logger.LogDebug(\"helm (stderr): {Error}\", error);\n            },\n            cancellationToken: context.CancellationToken).ConfigureAwait(false);\n\n        if (exitCode != 0)\n        {\n            var errorOutput = stderrBuilder.ToString().Trim();\n            var message = string.IsNullOrEmpty(errorOutput)\n                ? $\"helm uninstall for chart '{chart.Name}' failed with exit code {exitCode}\"\n                : $\"helm uninstall for chart '{chart.Name}' failed: {errorOutput}\";\n\n            throw new InvalidOperationException(message);\n        }\n\n        await deploymentStateManager.DeleteSectionAsync(stateSection, context.CancellationToken).ConfigureAwait(false);\n\n        logger.LogInformation(\n            \"Helm release '{ReleaseName}' uninstalled from namespace '{Namespace}'.\",\n            releaseName, @namespace);\n    }\n\n    private static (string ReleaseName, string Namespace) ResolveReleaseAndNamespace(KubernetesHelmChartResource chart)\n    {\n        var releaseName = chart.ReleaseName ?? chart.Name;\n        var @namespace = chart.Namespace ?? chart.Name;\n\n        // The fallback to chart.Name can produce a value that isn't a valid Helm release name or\n        // Kubernetes namespace (uppercase, too long, etc.) — Aspire resource names allow more than\n        // DNS labels do. Validate here so the caller gets a clear ArgumentException pointing at\n        // WithReleaseName / WithNamespace instead of an opaque helm CLI failure.","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Kubernetes/KubernetesHelmChartExtensions.cs#L438-L474","documentation":"UninstallHelmChartAsync runs 'helm uninstall' for the chart and throws InvalidOperationException when the helm process exits non-zero. The message includes helm's stderr when captured, otherwise just the exit code. This happens before the deployment state section is cleaned up.","triggerScenarios":"helm uninstall returns non-zero: release not found under the expected name, cluster unreachable, RBAC denial, or helm timing out waiting for resource deletion.","commonSituations":"Release already uninstalled out-of-band (helm reports 'release: not found'); wrong kubeconfig context; stuck terminating resources blocking uninstall; namespace already deleted.","solutions":["Read the helm stderr in the message for the exact cause","If the release was already removed, the state can be cleaned up manually — verify with 'helm list -n <namespace>'","Check cluster connectivity and kubeconfig context","Resolve stuck resources (finalizers) that prevent deletion"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check the release exists before uninstalling\nvar ls = await RunHelmAsync(\"list -n \" + @namespace + \" -q\");\nbool exists = ls.Split('\\n', StringSplitOptions.RemoveEmptyEntries).Contains(releaseName);","typeGuard":null,"tryCatchPattern":"try { await UninstallHelmChartAsync(chart, ...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"helm uninstall\"))\n{ logger.LogError(ex, \"Helm uninstall failed: {Detail}\", ex.Message); }","preventionTips":["Verify the release exists (helm list) before uninstalling","Ensure the kubeconfig context points at the right cluster","Watch for stuck finalizers on resources that block deletion"],"tags":["kubernetes","helm","destroy","process"],"backgroundTag":"command-not-found","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}