{"record":{"id":"f14281e82e5f8cdf","repo":"microsoft/aspire","slug":"innerresource-azuresignalremulatorresource","errorCode":null,"errorMessage":"innerResource","messagePattern":"innerResource","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.SignalR/AzureSignalREmulatorResource.cs","lineNumber":14,"sourceCode":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n\nusing Aspire.Hosting.ApplicationModel;\n\nnamespace Aspire.Hosting.Azure;\n\n/// <summary>\n/// Wraps an <see cref=\"AzureSignalRResource\" /> in a type that exposes container extension methods.\n/// </summary>\n/// <param name=\"innerResource\">The inner resource used to store annotations.</param>\npublic class AzureSignalREmulatorResource(AzureSignalRResource innerResource) : ContainerResource(innerResource.Name), IResource\n{\n    private readonly AzureSignalRResource _innerResource = innerResource ?? throw new ArgumentNullException(nameof(innerResource));\n\n    /// <inheritdoc/>\n    public override ResourceAnnotationCollection Annotations => _innerResource.Annotations;\n}\n","sourceCodeStart":1,"sourceCodeEnd":19,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.SignalR/AzureSignalREmulatorResource.cs#L1-L19","documentation":"AzureSignalREmulatorResource throws ArgumentNullException when the inner AzureSignalRResource is null. The emulator wrapper stores all annotations on the inner resource, so a null inner resource would break every annotation operation.","triggerScenarios":"Constructing AzureSignalREmulatorResource directly with a null AzureSignalRResource argument, e.g. in RunAsEmulator call chains where the SignalR resource was not resolved.","commonSituations":"Custom code that looks up the AzureSignalRResource by name (returning null when not found) and passes it into the emulator wrapper; tests constructing the wrapper in isolation.","solutions":["Pass the .Resource of the AzureSignalRResource created by AddAzureSignalR into the wrapper.","Use builder.AddAzureSignalR(...).RunAsEmulator() instead of constructing the emulator resource manually.","Ensure the lookup that produced the inner resource cannot return null before constructing."],"exampleFix":"// before\nvar emulator = new AzureSignalREmulatorResource(FindSignalR(\"signalr\"));\n\n// after\nvar signalr = builder.AddAzureSignalR(\"signalr\");\nvar emulator = new AzureSignalREmulatorResource(signalr.Resource);","handlingStrategy":"validation","validationCode":"if (signalrResource is null) throw new InvalidOperationException(\"AddAzureSignalR must run before creating the emulator resource.\");","typeGuard":"if (signalrResource is not null) { var emulator = new AzureSignalREmulatorResource(signalrResource); }","tryCatchPattern":null,"preventionTips":["Use RunAsEmulator() on the SignalR builder instead of manual wrapping.","Never feed nullable resource lookups into wrapper constructors.","Keep resource creation and emulator configuration in one chain."],"tags":["argument-null","azure-signalr","emulator"],"backgroundTag":"null-argument","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"}