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
- Pass a non-null key string when constructing PipelineSummaryItem.
- Null-check or substitute a default label before constructing: key ?? "Unknown".
- 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
- Coalesce nullable labels with ?? before building summary items.
- Avoid constructing summary items directly from data that may be unresolved.
- Add unit tests for summary generation with nullable fields.
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
- Value cannot be null. (Parameter 'value')
- Cannot complete step: Reporter is not set.
- Cannot create task: Reporter is not set.
- ArgumentNullException for parameter 'callback' (callback is…
- ArgumentNullException for parameter 'resource' (resource is…
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)