{"record":{"id":"0768bbd1227546f0","repo":"microsoft/aspire","slug":"endpoint-option-names-cannot-be-empty","errorCode":null,"errorMessage":"Endpoint option names cannot be empty.","messagePattern":"Endpoint option names cannot be empty\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs","lineNumber":408,"sourceCode":"                nameof(options));\n        }\n\n        if (options.Endpoints is null)\n        {\n            return;\n        }\n\n        var names = new HashSet<string>(StringComparer.OrdinalIgnoreCase);\n        foreach (var endpoint in options.Endpoints)\n        {\n            if (endpoint is null)\n            {\n                throw new ArgumentException(\"Endpoint options cannot contain null values.\", nameof(options));\n            }\n\n            if (string.IsNullOrWhiteSpace(endpoint.Name))\n            {\n                throw new ArgumentException(\"Endpoint option names cannot be empty.\", nameof(options));\n            }\n\n            if (!names.Add(endpoint.Name))\n            {\n                throw new ArgumentException($\"Endpoint option '{endpoint.Name}' is configured more than once.\", nameof(options));\n            }\n        }\n    }\n\n    private static void ValidateOptionalWholeSecondDuration(TimeSpan? value, string paramName, TimeSpan? maximum = null)\n    {\n        if (value is null)\n        {\n            return;\n        }\n\n        if (value < TimeSpan.Zero)\n        {","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs#L390-L426","documentation":"Every endpoint option passed to PublishAsAzureSandbox must have a non-empty, non-whitespace Name. The name is used to identify the endpoint within the Azure sandbox group, so an unnamed endpoint cannot be mapped or referenced and is rejected at validation time.","triggerScenarios":"PublishAsAzureSandbox called with an AzureSandboxOptions whose Endpoints list contains an endpoint where EndpointOptions.Name is null, empty, or whitespace (e.g. new EndpointOptions { Name = \"\" }).","commonSituations":"Copy-pasting endpoint config and forgetting to set Name; setting Name from an environment variable or config key that is empty; constructing endpoint options with object-initializer omitting Name because it is mistakenly assumed optional.","solutions":["Set a non-empty Name on every endpoint option in options.Endpoints","Check the source of Name values (config/env) for empty strings before use","Add a local check: Endpoints.All(e => !string.IsNullOrWhiteSpace(e.Name))"],"exampleFix":"// before\nvar options = new AzureSandboxOptions { Endpoints = [new EndpointOptions { Name = \"\" }] };\n// after\nvar options = new AzureSandboxOptions { Endpoints = [new EndpointOptions { Name = \"https\" }] };","handlingStrategy":"validation","validationCode":"if (options.Endpoints.Any(e => string.IsNullOrWhiteSpace(e.Name))) throw new ArgumentException(\"Every endpoint needs a name\");","typeGuard":null,"tryCatchPattern":"try { builder.PublishAsAzureSandbox(resource, options); } catch (ArgumentException ex) when (ex.Message.Contains(\"names cannot be empty\")) { /* fix endpoint Name and retry */ }","preventionTips":["Always set Name in endpoint option object initializers","Validate config-sourced names for emptiness before use","Treat Name as required, not optional, in your own wrapper APIs"],"tags":["validation","arguments","azure-sandbox","endpoints"],"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"}