{"record":{"id":"4bbb42445f1656f7","repo":"microsoft/aspire","slug":"parent-azureservicebussubscriptionresource","errorCode":null,"errorMessage":"parent","messagePattern":"parent","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusSubscriptionResource.cs","lineNumber":42,"sourceCode":"[AspireExport(ExposeProperties = true)]\npublic class AzureServiceBusSubscriptionResource(string name, string subscriptionName, AzureServiceBusTopicResource parent)\n    : Resource(name), IResourceWithParent<AzureServiceBusTopicResource>, IResourceWithConnectionString, IResourceWithAzureFunctionsConfig\n{\n    private string _subscriptionName = ThrowIfNullOrEmpty(subscriptionName);\n\n    /// <summary>\n    /// The subscription name.\n    /// </summary>\n    public string SubscriptionName\n    {\n        get => _subscriptionName;\n        set => _subscriptionName = ThrowIfNullOrEmpty(value, nameof(subscriptionName));\n    }\n\n    /// <summary>\n    /// Gets the parent Azure Service Bus Topic resource.\n    /// </summary>\n    public AzureServiceBusTopicResource Parent { get; } = parent ?? throw new ArgumentNullException(nameof(parent));\n\n    /// <summary>\n    /// Gets the connection string expression for the Azure Service Bus Subscription.\n    /// </summary>\n    public ReferenceExpression ConnectionStringExpression => Parent.Parent.GetConnectionString(Parent.TopicName, SubscriptionName);\n\n    /// <summary>\n    /// A value that indicates whether this queue has dead letter support when\n    /// a message expires.\n    /// </summary>\n    public bool? DeadLetteringOnMessageExpiration { get; set; }\n\n    /// <summary>\n    /// ISO 8601 default message timespan to live value. This is the duration\n    /// after which the message expires, starting from when the message is\n    /// sent to Service Bus. This is the default value used when TimeToLive is\n    /// not set on a message itself.\n    /// </summary>","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusSubscriptionResource.cs#L24-L60","documentation":"The AzureServiceBusSubscriptionResource constructor throws ArgumentNullException when the parent topic resource is null. The library requires every subscription resource to be attached to a valid AzureServiceBusTopicResource so its connection string can be derived via the parent hierarchy.","triggerScenarios":"Calling the AzureServiceBusSubscriptionResource constructor directly (or a low-level extension/API that forwards to it) with a null AzureServiceBusTopicResource parent argument.","commonSituations":"Hand-constructing subscription resources in custom extension methods or tests; passing the result of a lookup that returned null (e.g. resource not found in the model) into the constructor.","solutions":["Pass the AzureServiceBusTopicResource you created with AddAzureServiceBusTopic directly into the constructor or subscription extension call.","Check that the topic-creating call actually returned a non-null resource before constructing the subscription.","Prefer the AddAzureServiceBusSubscription extension over manual construction."],"exampleFix":"// before\nvar sub = new AzureServiceBusSubscriptionResource(\"orders-sub\", \"orders\", GetTopicMaybeNull());\n\n// after\nvar topic = builder.AddAzureServiceBusTopic(\"orders\", \"orders-topic\");\nvar sub = new AzureServiceBusSubscriptionResource(\"orders-sub\", \"orders\", topic.Resource);","handlingStrategy":"validation","validationCode":"if (topicResource is null) throw new InvalidOperationException(\"Topic resource must be created before the subscription.\");","typeGuard":"if (topicResource is not null) { var sub = new AzureServiceBusSubscriptionResource(name, subName, topicResource); }","tryCatchPattern":null,"preventionTips":["Always create topics via AddAzureServiceBusTopic before adding subscriptions.","Never pass lookup results that can be null directly into resource constructors.","Prefer extension methods over direct resource construction."],"tags":["argument-null","azure-servicebus","constructor"],"backgroundTag":"null-argument","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}