microsoft/aspire · error · ArgumentException

Endpoint option names cannot be empty.

Error message

Endpoint option names cannot be empty.

What it means

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.

Solutions

  1. Set a non-empty Name on every endpoint option in options.Endpoints
  2. Check the source of Name values (config/env) for empty strings before use
  3. Add a local check: Endpoints.All(e => !string.IsNullOrWhiteSpace(e.Name))

Example fix

// before
var options = new AzureSandboxOptions { Endpoints = [new EndpointOptions { Name = "" }] };
// after
var options = new AzureSandboxOptions { Endpoints = [new EndpointOptions { Name = "https" }] };
Defensive patterns

Strategy: validation

Validate before calling

if (options.Endpoints.Any(e => string.IsNullOrWhiteSpace(e.Name))) throw new ArgumentException("Every endpoint needs a name");

Try / catch

try { builder.PublishAsAzureSandbox(resource, options); } catch (ArgumentException ex) when (ex.Message.Contains("names cannot be empty")) { /* fix endpoint Name and retry */ }

Prevention

When it happens

Trigger: PublishAsAzureSandbox called with an AzureSandboxOptions whose Endpoints list contains an endpoint where EndpointOptions.Name is null, empty, or whitespace (e.g. new EndpointOptions { Name = "" }).

Common situations: 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.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/0768bbd1227546f0. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs:408

                nameof(options));
        }

        if (options.Endpoints is null)
        {
            return;
        }

        var names = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
        foreach (var endpoint in options.Endpoints)
        {
            if (endpoint is null)
            {
                throw new ArgumentException("Endpoint options cannot contain null values.", nameof(options));
            }

            if (string.IsNullOrWhiteSpace(endpoint.Name))
            {
                throw new ArgumentException("Endpoint option names cannot be empty.", nameof(options));
            }

            if (!names.Add(endpoint.Name))
            {
                throw new ArgumentException($"Endpoint option '{endpoint.Name}' is configured more than once.", nameof(options));
            }
        }
    }

    private static void ValidateOptionalWholeSecondDuration(TimeSpan? value, string paramName, TimeSpan? maximum = null)
    {
        if (value is null)
        {
            return;
        }

        if (value < TimeSpan.Zero)
        {

View on GitHub (pinned to 25830f84bd)