{"record":{"id":"5eb3f3d8695961ec","repo":"microsoft/aspire","slug":"launch-arguments-must-contain-at-least-one-entry","errorCode":null,"errorMessage":"Launch arguments must contain at least one entry.","messagePattern":"Launch arguments must contain at least one entry\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/ApplicationModel/ProjectLaunchArgsOverrideAnnotation.cs","lineNumber":66,"sourceCode":"\n    internal void Apply(IList<string> projectArgs, string projectPath, string? configuration)\n    {\n        projectArgs.AddRange(Arguments);\n        projectArgs.Add(projectPath);\n\n        if (!string.IsNullOrEmpty(configuration))\n        {\n            projectArgs.AddRange([\"--configuration\", configuration]);\n        }\n    }\n\n    private static IReadOnlyList<string> ValidateArguments(IReadOnlyList<string> arguments)\n    {\n        ArgumentNullException.ThrowIfNull(arguments);\n\n        if (arguments.Count == 0)\n        {\n            throw new ArgumentException(\"Launch arguments must contain at least one entry.\", nameof(arguments));\n        }\n\n        return arguments;\n    }\n\n    private static string? ValidateLeadingResourceArgumentToRemove(string? leadingResourceArgumentToRemove)\n    {\n        if (leadingResourceArgumentToRemove is not null && leadingResourceArgumentToRemove.Length == 0)\n        {\n            throw new ArgumentException(\"The leading resource argument to remove cannot be empty.\", nameof(leadingResourceArgumentToRemove));\n        }\n\n        return leadingResourceArgumentToRemove;\n    }\n}\n","sourceCodeStart":48,"sourceCodeEnd":82,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/ApplicationModel/ProjectLaunchArgsOverrideAnnotation.cs#L48-L82","documentation":"ProjectLaunchArgsOverrideAnnotation.ValidateArguments rejects an empty arguments list. An override annotation that replaced launch arguments with an empty set is almost certainly a mistake — the project would be started with no arguments at all — so the annotation fails fast.","triggerScenarios":"new ProjectLaunchArgsOverrideAnnotation(Array.Empty<string>()) or passing a filtered/derived list that ended up empty to the annotation constructor.","commonSituations":"Building the argument list by filtering user-supplied args where none matched; passing an uninitialized array; removing the leading resource argument and then assigning the now-empty remainder.","solutions":["Supply at least one launch argument, e.g. new ProjectLaunchArgsOverrideAnnotation([\"run\"]...)","Guard before constructing: if (args.Count == 0) args = [\"run\"];","If no override is needed, don't add the annotation instead of passing an empty list"],"exampleFix":"// before\nvar annotation = new ProjectLaunchArgsOverrideAnnotation(filteredArgs); // filteredArgs == []\n// after\nvar annotation = filteredArgs.Count > 0\n    ? new ProjectLaunchArgsOverrideAnnotation(filteredArgs)\n    : new ProjectLaunchArgsOverrideAnnotation([\"run\"]);","handlingStrategy":"validation","validationCode":"if (args.Count == 0) args = [\"run\"]; // or skip adding the annotation\nvar annotation = new ProjectLaunchArgsOverrideAnnotation(args);","typeGuard":null,"tryCatchPattern":"try { new ProjectLaunchArgsOverrideAnnotation(args); } catch (ArgumentException) { /* fall back to no override */ }","preventionTips":["Check Count after filtering args before constructing the annotation","Skip adding the override annotation when no replacement args exist"],"tags":["launch-configuration","argument-validation","aspire-hosting"],"backgroundTag":"empty-required-field","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"}