{"record":{"id":"e2f29b1bbacafbf4","repo":"microsoft/aspire","slug":"argumentnullexception-for-parameter-args-args-is-null-e2f29b","errorCode":null,"errorMessage":"ArgumentNullException for parameter 'args' (args is null).","messagePattern":"ArgumentNullException for parameter 'args' \\(args is null\\)\\.","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/ApplicationModel/CommandLineArgsEditor.cs","lineNumber":12,"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\nnamespace Aspire.Hosting.ApplicationModel;\n\n/// <summary>\n/// Provides an ATS-first editor for command-line arguments within polyglot callbacks.\n/// </summary>\n[AspireExport]\ninternal sealed class CommandLineArgsEditor(IList<object> args)\n{\n    private readonly IList<object> _args = args ?? throw new ArgumentNullException(nameof(args));\n\n    /// <summary>\n    /// Adds a command-line argument.\n    /// </summary>\n    /// <param name=\"value\">The argument to add.</param>\n    [AspireExport]\n    public void Add(\n        [AspireUnion(\n            typeof(string),\n            typeof(ReferenceExpression),\n            typeof(EndpointReference),\n            typeof(IResourceBuilder<ParameterResource>),\n            typeof(IResourceBuilder<IResourceWithConnectionString>),\n            typeof(IExpressionValue))]\n        object value)\n    {\n        ArgumentNullException.ThrowIfNull(value);\n        _args.Add(value);","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/ApplicationModel/CommandLineArgsEditor.cs#L1-L30","documentation":"Primary constructor null guard in CommandLineArgsEditor: the 'args' list passed to the editor is null. The editor mutates the shared argument list in place (ATS-first editing for polyglot callbacks), so a null list cannot be adapted to.","triggerScenarios":"Constructing CommandLineArgsEditor(null), e.g. from exported callback tooling where the context's Args list was null or not passed through.","commonSituations":"Polyglot (non-C#) callback hosts wiring the editor without the args collection; custom pipelines constructing the editor before args exist.","solutions":["Pass the CommandLineArgsCallbackContext's Args list (or a valid IList<object>) to the editor","Initialize an empty List<object> if no arguments exist yet"],"exampleFix":"// before\nvar editor = new CommandLineArgsEditor(null);\n// after\nvar editor = new CommandLineArgsEditor(context.Args);","handlingStrategy":"validation","validationCode":"if (args is null) args = new List<object>();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass context.Args directly into the editor","Ensure exported callback environments supply a non-null args collection"],"tags":["null-argument","internal-api"],"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"}