microsoft/aspire · error · ArgumentException

cert-manager resource name

Error message

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.

What it means

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.

Solutions

  1. Shorten the resource name to 57 characters or fewer.
  2. If the name is built from variables, truncate or hash the variable portion before calling AddCertManager.
  3. Split a long compound name (e.g. 'cert-manager-prod-us-west-2') into a shorter resource name.

Example fix

// before
builder.AddCertManager("cert-manager-production-environment-us-west-2");

// after
builder.AddCertManager("cert-manager-prod");
Defensive patterns

Strategy: validation

Validate before calling

if (name.Length > 57) throw new ArgumentException($"Name must be <= 57 chars, got {name.Length}", nameof(name));

Prevention

When it happens

Trigger: Calling AddCertManager with a name longer than 57 characters (MaxResourceNameLength - "-chart" suffix length).

Common situations: Generating cert-manager resource names programmatically from long environment or cluster names, or copy-pasting a fully qualified name into AddCertManager.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/b4b8ae09fbcc082a. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.Kubernetes/CertManagerExtensions.cs:95

    /// <see cref="CertManagerResource.HelmChart"/>.
    /// </para>
    /// </remarks>
    /// <ats-remarks />
    [AspireExport]
    public static IResourceBuilder<CertManagerResource> AddCertManager(
        this IResourceBuilder<KubernetesEnvironmentResource> builder,
        [ResourceName] string name,
        string? chartVersion = null)
    {
        ArgumentNullException.ThrowIfNull(builder);
        ArgumentException.ThrowIfNullOrEmpty(name);

        // Keep room for the "-chart" suffix we append for the underlying helm chart resource.
        // Without this guard, an otherwise-valid 64-char name would build successfully here
        // and then explode inside AddHelmChart with a less-clear "name too long" message.
        if (name.Length > MaxResourceNameLength - ChartNameSuffix.Length)
        {
            throw new ArgumentException(
                $"cert-manager resource name '{name}' is too long. The maximum length is {MaxResourceNameLength - ChartNameSuffix.Length} characters because " +
                $"a companion Helm chart resource is registered as '{{name}}{ChartNameSuffix}' which must itself fit within the {MaxResourceNameLength}-character Aspire resource name limit.",
                nameof(name));
        }

        var version = chartVersion ?? DefaultChartVersion;

        // The helm chart is exposed in the model under "{name}-chart" so the user-facing
        // CertManagerResource can keep the natural "{name}" identifier without colliding.
        // Both show up in the dashboard / generated artifacts: the chart is what actually
        // installs cert-manager, and the wrapper is what hosts the typed issuer children.
        var chartName = $"{name}{ChartNameSuffix}";

        var chartBuilder = builder
            .AddHelmChart(chartName, DefaultChartReference, version)
            .WithHelmValue("crds.enabled", "true")
            // Gateway API support is opt-in in the cert-manager chart. Without these values
            // cert-manager will not provision Certificates for Gateway listeners.

View on GitHub (pinned to 25830f84bd)