{"record":{"id":"63d87ea052c2784d","repo":"microsoft/aspire","slug":"value-cannot-be-null-parameter-launchprofilename","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'launchProfileName')","messagePattern":"Value cannot be null\\. \\(Parameter 'launchProfileName'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/DefaultLaunchProfileAnnotation.cs","lineNumber":14,"sourceCode":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n\nusing System.Diagnostics;\n\nnamespace Aspire.Hosting.ApplicationModel;\n\n/// <summary>\n/// An annotation that specifies the default launch profile for a resource.\n/// </summary>\n[DebuggerDisplay(\"Type = {GetType().Name,nq}, LaunchProfileName = {LaunchProfileName}\")]\npublic sealed class DefaultLaunchProfileAnnotation(string launchProfileName) : IResourceAnnotation\n{\n    private readonly string _launchProfileName = launchProfileName ?? throw new ArgumentNullException(nameof(launchProfileName));\n\n    /// <summary>\n    /// The name of the default launch profile.\n    /// </summary>\n    public string LaunchProfileName => _launchProfileName;\n}\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/DefaultLaunchProfileAnnotation.cs#L1-L21","documentation":"DefaultLaunchProfileAnnotation's constructor performs a null check on launchProfileName and throws ArgumentNullException when it is null. The annotation exists to designate which launch settings profile a project resource should use, so a null name is meaningless.","triggerScenarios":"Constructing new DefaultLaunchProfileAnnotation(null) — typically by passing a variable or configuration lookup that resolved to null, e.g. environment[\"PROFILE\"] or an optional parameter.","commonSituations":"Reading the profile name from configuration/environment that is not set, refactoring a method to return a nullable string, or deserializing options where the field is missing.","solutions":["Provide a concrete profile name, e.g. \"https\" or \"http\".","Check the source value for null/empty before constructing the annotation and fall back to a default.","If the profile is optional, skip adding the annotation rather than adding one with a null name."],"exampleFix":"// before\nvar profile = Environment.GetEnvironmentVariable(\"LAUNCH_PROFILE\");\nbuilder.AddAnnotation(new DefaultLaunchProfileAnnotation(profile)); // null -> throws\n// after\nvar profile = Environment.GetEnvironmentVariable(\"LAUNCH_PROFILE\") ?? \"https\";\nbuilder.AddAnnotation(new DefaultLaunchProfileAnnotation(profile));","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(profileName)) profileName = \"https\";\nbuilder.AddAnnotation(new DefaultLaunchProfileAnnotation(profileName));","typeGuard":null,"tryCatchPattern":"try { builder.AddAnnotation(new DefaultLaunchProfileAnnotation(profileName)); }\ncatch (ArgumentNullException) { /* skip or default profile */ }","preventionTips":["Coalesce nullable profile sources to a default before constructing annotations","Use string interpolation only after a null check","Avoid passing environment/config lookups directly into required parameters"],"tags":["null-argument","annotations","launch-profiles"],"backgroundTag":"null-argument","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"}