{"record":{"id":"7586480ac4d95cdb","repo":"microsoft/aspire","slug":"value-cannot-be-null-parameter-key","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'key')","messagePattern":"Value cannot be null\\. \\(Parameter 'key'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/Pipelines/PipelineSummaryItem.cs","lineNumber":21,"sourceCode":"\nusing System.Diagnostics.CodeAnalysis;\n\nnamespace Aspire.Hosting.Pipelines;\n\n/// <summary>\n/// Represents a single item in a <see cref=\"PipelineSummary\"/>, consisting of a key, a value,\n/// and a flag indicating whether the value contains Markdown formatting.\n/// </summary>\n/// <param name=\"key\">The key or label for the summary item.</param>\n/// <param name=\"value\">The string value for the summary item.</param>\n/// <param name=\"enableMarkdown\">Whether the <paramref name=\"value\"/> contains Markdown formatting.</param>\n[Experimental(\"ASPIREPIPELINES001\", UrlFormat = \"https://aka.ms/aspire/diagnostics/{0}\")]\npublic sealed class PipelineSummaryItem(string key, string value, bool enableMarkdown)\n{\n    /// <summary>\n    /// Gets the key or label for the summary item (e.g., \"Namespace\", \"URL\").\n    /// </summary>\n    public string Key { get; } = key ?? throw new ArgumentNullException(nameof(key));\n\n    /// <summary>\n    /// Gets the string value for the summary item.\n    /// </summary>\n    public string Value { get; } = value ?? throw new ArgumentNullException(nameof(value));\n\n    /// <summary>\n    /// Gets a value indicating whether <see cref=\"Value\"/> contains Markdown formatting that\n    /// should be rendered by the CLI output.\n    /// </summary>\n    public bool EnableMarkdown { get; } = enableMarkdown;\n}\n","sourceCodeStart":3,"sourceCodeEnd":34,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/Pipelines/PipelineSummaryItem.cs#L3-L34","documentation":"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.","triggerScenarios":"Calling new PipelineSummaryItem(null, value) or new PipelineSummaryItem(null, value, enableMarkdown) from a custom pipeline reporting step.","commonSituations":"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.","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."],"exampleFix":"// before\nvar item = new PipelineSummaryItem(namespaceName, value, enableMarkdown: false);\n\n// after\nvar item = new PipelineSummaryItem(namespaceName ?? \"Unknown\", value, enableMarkdown: false);","handlingStrategy":"validation","validationCode":"if (key is null)\n{\n    key = \"Unknown\"; // or throw with a clear message\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var item = new PipelineSummaryItem(key, value);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"key\")\n{\n    logger.LogWarning(\"Summary key was null; skipping item.\");\n}","preventionTips":["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."],"tags":["argument-null","pipelines","reporting"],"backgroundTag":"null-argument","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}