microsoft/aspire · error · ArgumentException
Connector operations cannot contain null values.
Error message
Connector operations cannot contain null values.
What it means
While building the connector definition, WithConnector iterates options.Operations and throws this ArgumentException if any element is null. A null operation has no name or behavior, so the library rejects it up front rather than producing an invalid Bicep/resource definition.
Solutions
- Remove null entries from options.Operations before calling WithConnector.
- Use collection expressions or LINQ .Where(op => op is not null) to filter the list.
- Fix the source (config binding or factory) that produces null operation objects.
Example fix
// before
Operations = new[] { op1, null, op2 }
// after
Operations = new[] { op1, op2 } Defensive patterns
Strategy: type-guard
Validate before calling
if (options.Operations.Any(op => op is null))
{
throw new InvalidOperationException("Operations contains null entries.");
} Type guard
bool HasNullOperation(IEnumerable<AzureConnectorNamespaceConnectorOperation?> ops) => ops.Any(op => op is null);
Try / catch
try { builder.WithConnector(options); }
catch (ArgumentException ex) when (ex.Message.Contains("null values"))
{
// filter nulls from options.Operations and retry
} Prevention
- Filter collections with .Where(op => op is not null) before assignment.
- Avoid array initializers with placeholder nulls.
- Check deserialization results for null elements.
When it happens
Trigger: Passing an Operations array that contains a null element, e.g. Operations = new AzureConnectorNamespaceConnectorOperation?[] { null } or a collection built with LINQ that can produce null entries.
Common situations: Array initializers with placeholder nulls; deserialized config where an operation object failed to bind; union of multiple operation lists containing nulls.
Related errors
- At least one connector operation must be explicitly…
- Connector operation ' ' is configured more than once.
- Access policy ' ' is already registered on connector…
- Access policy resource
- Connector connection
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/b819d4cda6579e21.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure.ConnectorNamespace/AzureConnectorNamespaceExtensions.cs:624
if (options.Operations is null || options.Operations.Length == 0)
{
throw new ArgumentException(
"At least one connector operation must be explicitly allow-listed.",
nameof(options));
}
var operationNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
var connectorDefinition = new AzureConnectorNamespaceMcpConnectorDefinition(
connectorName,
options.DisplayName,
options.Description,
connection.Resource);
foreach (var operation in options.Operations)
{
if (operation is null)
{
throw new ArgumentException("Connector operations cannot contain null values.", nameof(options));
}
ArgumentException.ThrowIfNullOrWhiteSpace(operation.Name);
if (!operationNames.Add(operation.Name))
{
throw new ArgumentException(
$"Connector operation '{operation.Name}' is configured more than once.",
nameof(options));
}
connectorDefinition.Operations.Add(new AzureConnectorNamespaceMcpOperationDefinition(
operation.Name,
operation.DisplayName,
operation.Description));
}
builder.Resource.Connectors.Add(connectorDefinition);
return builder;View on GitHub (pinned to 25830f84bd)