microsoft/aspire · error · ArgumentNullException
Object value cannot be null (ArgumentNullException: parent)
Error message
Object value cannot be null (ArgumentNullException: parent)
What it means
The AzureConnectorNamespaceConnectionResource constructor requires a non-null parent Connector Namespace resource; the parent's Name is used to build the connection's Bicep identifier. Passing null parent throws ArgumentNullException.
Solutions
- Use the AddConnection extension on the Connector Namespace resource builder, which supplies the parent automatically
- Build the namespace with AddAzureConnectorNamespace before creating connections
- Fix factory/DI code so the parent resource is resolved before connection creation
Example fix
// before var conn = new AzureConnectorNamespaceConnectionResource(name, connectionName, displayName, null!, connectorName); // after nsBuilder.AddConnection(name, connectorName, options => options.ConnectionName = connectionName);
Defensive patterns
Strategy: validation
Validate before calling
if (parent is null) throw new InvalidOperationException("Connector Namespace parent must be built before creating connections."); Type guard
bool canCreate = parent is not null;
Try / catch
try { new AzureConnectorNamespaceConnectionResource(...); } catch (ArgumentNullException ex) when (ex.ParamName == "parent") { /* use AddConnection instead */ } Prevention
- Use the AddConnection builder extension rather than direct construction
- Ensure the namespace builder exists before wiring connections
- Avoid factories that can return null parents
When it happens
Trigger: Constructing AzureConnectorNamespaceConnectionResource directly with parent = null, e.g. calling AddConnection with a builder whose Resource is null or building the connection before the namespace resource exists.
Common situations: Manual provisioning-model construction bypassing AddConnection; dependency-injection or factory code that resolves the parent lazily and yields null; copy-pasted resource constructors where the parent argument was dropped.
Related errors
- Object value cannot be null (ArgumentNullException: parent)
- Value cannot be null. (Parameter 'config')
- Value cannot be null. (Parameter 'parent')
- Value cannot be null. (Parameter 'parent')
- Value cannot be null. (Parameter 'parent')
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/d36462c6bcab06ad.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure.ConnectorNamespace/AzureConnectorNamespaceConnectionResource.cs:35
{
/// <summary>
/// Initializes a new instance of the <see cref="AzureConnectorNamespaceConnectionResource"/> class.
/// </summary>
/// <param name="name">The Aspire resource name.</param>
/// <param name="connectionName">The Azure connector connection name.</param>
/// <param name="connectorName">The connector catalog name.</param>
/// <param name="displayName">The friendly display name shown for the connection.</param>
/// <param name="parent">The parent connector namespace resource.</param>
public AzureConnectorNamespaceConnectionResource(string name, string connectionName, string connectorName, string? displayName, AzureConnectorNamespaceResource parent)
: base(name)
{
ArgumentException.ThrowIfNullOrWhiteSpace(connectionName);
ArgumentException.ThrowIfNullOrWhiteSpace(connectorName);
ConnectionName = connectionName;
ConnectorName = connectorName;
DisplayName = displayName;
Parent = parent ?? throw new ArgumentNullException(nameof(parent));
BicepIdentifier = ConnectorNamespaceBicepIdentifiers.CreateConnection(parent.Name, name);
}
/// <summary>
/// Gets the Azure connector connection name.
/// </summary>
public string ConnectionName { get; }
/// <summary>
/// Gets the connector catalog name.
/// </summary>
public string ConnectorName { get; }
/// <summary>
/// Gets the friendly display name shown for the connection.
/// </summary>
public string? DisplayName { get; }
View on GitHub (pinned to 25830f84bd)