{"record":{"id":"41ec1764f063ec8f","repo":"microsoft/aspire","slug":"the-executable-path-cannot-be-null-empty-or-whitespace","errorCode":null,"errorMessage":"The executable path cannot be null, empty, or whitespace.","messagePattern":"The executable path cannot be null, empty, or whitespace\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/ApplicationModel/ProcessCommandSpec.cs","lineNumber":27,"sourceCode":"/// Describes a local process that is started when a process-backed resource command executes.\n/// </summary>\n/// <param name=\"executablePath\">\n/// The executable path or command name to start. Command names are resolved from the AppHost process PATH.\n/// </param>\n[Experimental(\"ASPIREPROCESSCOMMAND001\", UrlFormat = \"https://aka.ms/aspire/diagnostics/{0}\")]\npublic sealed class ProcessCommandSpec(string executablePath)\n{\n    /// <summary>\n    /// Gets the executable path or command name to start.\n    /// </summary>\n    /// <remarks>\n    /// <para>\n    /// Command names without directory separators are resolved from the AppHost process PATH before starting the process.\n    /// </para>\n    /// </remarks>\n    public string ExecutablePath { get; } = !string.IsNullOrWhiteSpace(executablePath)\n        ? executablePath\n        : throw new ArgumentException(\"The executable path cannot be null, empty, or whitespace.\", nameof(executablePath));\n\n    /// <summary>\n    /// Gets or sets the working directory for the process.\n    /// </summary>\n    public string? WorkingDirectory { get; init; }\n\n    /// <summary>\n    /// Gets or sets the command-line arguments for the process.\n    /// </summary>\n    /// <remarks>\n    /// <para>\n    /// Arguments are passed using <see cref=\"System.Diagnostics.ProcessStartInfo.ArgumentList\"/> so that each item is\n    /// escaped according to the current platform's process-start rules.\n    /// </para>\n    /// </remarks>\n    public IReadOnlyList<string> Arguments { get; init; } = [];\n\n    /// <summary>","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/ApplicationModel/ProcessCommandSpec.cs#L9-L45","documentation":"ProcessCommandSpec validates its required executablePath constructor argument with IsNullOrWhiteSpace and throws ArgumentException when it is null, empty, or whitespace. The executable path is fundamental to launching the process, so an empty value cannot be defaulted.","triggerScenarios":"new ProcessCommandSpec(null/\"\"/\"   \", ...) — passing an unresolved variable, an empty config value, or a path derived from a failed lookup.","commonSituations":"A tool name resolved from an environment variable or config key that was unset; a path computed by string concatenation that yielded empty; trimming a value that was only whitespace.","solutions":["Pass a real executable path or command name, e.g. new ProcessCommandSpec(\"dotnet\", ...)","Validate the source value before constructing: if (string.IsNullOrWhiteSpace(path)) throw ...","If the path comes from an env var, fall back to a known default or fail with a clearer message"],"exampleFix":"// before\nvar spec = new ProcessCommandSpec(env[\"TOOL_PATH\"], ...);\n// after\nvar spec = new ProcessCommandSpec(\n    string.IsNullOrWhiteSpace(env[\"TOOL_PATH\"]) ? \"tool\" : env[\"TOOL_PATH\"], ...);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(executablePath)) throw new ArgumentException(\"Executable path is required.\");\nvar spec = new ProcessCommandSpec(executablePath, ...);","typeGuard":"bool HasExecutable([NotNullWhen(true)] string? p) => !string.IsNullOrWhiteSpace(p);","tryCatchPattern":"try { var spec = new ProcessCommandSpec(path, ...); } catch (ArgumentException ex) { /* resolve path from env/config fallback */ }","preventionTips":["Validate env-var/config-sourced paths before constructing ProcessCommandSpec","Trim and check user-supplied tool paths"],"tags":["process","argument-validation","aspire-hosting"],"backgroundTag":"invalid-argument-value","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"}