microsoft/aspire · error · ArgumentNullException

Value cannot be null. (Parameter 'key')

Error message

Value cannot be null. (Parameter 'key')

What it means

PipelineSummaryItem's constructor throws ArgumentNullException with parameter name 'key' when the summary item key/label (e.g. "Namespace", "URL") is null. The key is a get-only required property assigned inline with a null check, so any construction with a null key fails immediately. The library treats a keyless summary row as a caller bug rather than tolerating it.

Solutions

  1. Pass a non-null key string when constructing PipelineSummaryItem.
  2. Null-check or substitute a default label before constructing: key ?? "Unknown".
  3. Fix the upstream computation so the label (e.g. URL, namespace) is resolved before summary creation.

Example fix

// before
var item = new PipelineSummaryItem(namespaceName, value, enableMarkdown: false);

// after
var item = new PipelineSummaryItem(namespaceName ?? "Unknown", value, enableMarkdown: false);
Defensive patterns

Strategy: validation

Validate before calling

if (key is null)
{
    key = "Unknown"; // or throw with a clear message
}

Try / catch

try
{
    var item = new PipelineSummaryItem(key, value);
}
catch (ArgumentNullException ex) when (ex.ParamName == "key")
{
    logger.LogWarning("Summary key was null; skipping item.");
}

Prevention

When it happens

Trigger: Calling new PipelineSummaryItem(null, value) or new PipelineSummaryItem(null, value, enableMarkdown) from a custom pipeline reporting step.

Common situations: A reporting/pipeline step builds summary items from data where the label field can be null (e.g. a URL or namespace that was never resolved), and the null is passed straight into the constructor.

Related errors


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

Appendix: source

Thrown at src/Aspire.Hosting/Pipelines/PipelineSummaryItem.cs:21

using System.Diagnostics.CodeAnalysis;

namespace Aspire.Hosting.Pipelines;

/// <summary>
/// Represents a single item in a <see cref="PipelineSummary"/>, consisting of a key, a value,
/// and a flag indicating whether the value contains Markdown formatting.
/// </summary>
/// <param name="key">The key or label for the summary item.</param>
/// <param name="value">The string value for the summary item.</param>
/// <param name="enableMarkdown">Whether the <paramref name="value"/> contains Markdown formatting.</param>
[Experimental("ASPIREPIPELINES001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")]
public sealed class PipelineSummaryItem(string key, string value, bool enableMarkdown)
{
    /// <summary>
    /// Gets the key or label for the summary item (e.g., "Namespace", "URL").
    /// </summary>
    public string Key { get; } = key ?? throw new ArgumentNullException(nameof(key));

    /// <summary>
    /// Gets the string value for the summary item.
    /// </summary>
    public string Value { get; } = value ?? throw new ArgumentNullException(nameof(value));

    /// <summary>
    /// Gets a value indicating whether <see cref="Value"/> contains Markdown formatting that
    /// should be rendered by the CLI output.
    /// </summary>
    public bool EnableMarkdown { get; } = enableMarkdown;
}

View on GitHub (pinned to 25830f84bd)