{"record":{"id":"b4b8ae09fbcc082a","repo":"microsoft/aspire","slug":"cert-manager-resource-name-name-is-too-long-the-maximum","errorCode":null,"errorMessage":"cert-manager resource name '{name}' is too long. The maximum length is 57 characters because a companion Helm chart resource is registered as '{name}-chart' which must itself fit within the 64-character Aspire resource name limit.","messagePattern":"cert-manager resource name '(.+?)' is too long\\. The maximum length is 57 characters because a companion Helm chart resource is registered as '(.+?)-chart' which must itself fit within the 64-character Aspire resource name limit\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Kubernetes/CertManagerExtensions.cs","lineNumber":95,"sourceCode":"    /// <see cref=\"CertManagerResource.HelmChart\"/>.\n    /// </para>\n    /// </remarks>\n    /// <ats-remarks />\n    [AspireExport]\n    public static IResourceBuilder<CertManagerResource> AddCertManager(\n        this IResourceBuilder<KubernetesEnvironmentResource> builder,\n        [ResourceName] string name,\n        string? chartVersion = null)\n    {\n        ArgumentNullException.ThrowIfNull(builder);\n        ArgumentException.ThrowIfNullOrEmpty(name);\n\n        // Keep room for the \"-chart\" suffix we append for the underlying helm chart resource.\n        // Without this guard, an otherwise-valid 64-char name would build successfully here\n        // and then explode inside AddHelmChart with a less-clear \"name too long\" message.\n        if (name.Length > MaxResourceNameLength - ChartNameSuffix.Length)\n        {\n            throw new ArgumentException(\n                $\"cert-manager resource name '{name}' is too long. The maximum length is {MaxResourceNameLength - ChartNameSuffix.Length} characters because \" +\n                $\"a companion Helm chart resource is registered as '{{name}}{ChartNameSuffix}' which must itself fit within the {MaxResourceNameLength}-character Aspire resource name limit.\",\n                nameof(name));\n        }\n\n        var version = chartVersion ?? DefaultChartVersion;\n\n        // The helm chart is exposed in the model under \"{name}-chart\" so the user-facing\n        // CertManagerResource can keep the natural \"{name}\" identifier without colliding.\n        // Both show up in the dashboard / generated artifacts: the chart is what actually\n        // installs cert-manager, and the wrapper is what hosts the typed issuer children.\n        var chartName = $\"{name}{ChartNameSuffix}\";\n\n        var chartBuilder = builder\n            .AddHelmChart(chartName, DefaultChartReference, version)\n            .WithHelmValue(\"crds.enabled\", \"true\")\n            // Gateway API support is opt-in in the cert-manager chart. Without these values\n            // cert-manager will not provision Certificates for Gateway listeners.","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Kubernetes/CertManagerExtensions.cs#L77-L113","documentation":"AddCertManager registers a companion Helm chart resource named '{name}-chart'. Aspire resource names are capped at 64 characters, so the cert-manager name must be at most 57 characters; otherwise the derived chart name would overflow. This early guard fails fast with a clearer message than the later AddHelmChart error.","triggerScenarios":"Calling AddCertManager with a name longer than 57 characters (MaxResourceNameLength - \"-chart\" suffix length).","commonSituations":"Generating cert-manager resource names programmatically from long environment or cluster names, or copy-pasting a fully qualified name into AddCertManager.","solutions":["Shorten the resource name to 57 characters or fewer.","If the name is built from variables, truncate or hash the variable portion before calling AddCertManager.","Split a long compound name (e.g. 'cert-manager-prod-us-west-2') into a shorter resource name."],"exampleFix":"// before\nbuilder.AddCertManager(\"cert-manager-production-environment-us-west-2\");\n\n// after\nbuilder.AddCertManager(\"cert-manager-prod\");","handlingStrategy":"validation","validationCode":"if (name.Length > 57) throw new ArgumentException($\"Name must be <= 57 chars, got {name.Length}\", nameof(name));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep resource names short and environment-agnostic.","Truncate or hash programmatically generated names before registering resources."],"tags":["kubernetes","cert-manager","naming","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}