{"record":{"id":"d3b3a9cf96442b0b","repo":"microsoft/aspire","slug":"value-cannot-be-null-parameter-innerresource-d3b3a9","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'innerResource')","messagePattern":"Value cannot be null\\. \\(Parameter 'innerResource'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsEmulatorResource.cs","lineNumber":21,"sourceCode":"\nusing Aspire.Hosting.ApplicationModel;\n\nnamespace Aspire.Hosting.Azure;\n\n/// <summary>\n/// Wraps an <see cref=\"AzureEventHubsResource\" /> in a type that exposes container extension methods.\n/// </summary>\n/// <param name=\"innerResource\">The inner resource used to store annotations.</param>\npublic class AzureEventHubsEmulatorResource(AzureEventHubsResource innerResource)\n    : ContainerResource(innerResource.Name), IResource\n{\n    // The path to the emulator configuration file in the container.\n    // The path to the emulator configuration files in the container.\n    internal const string EmulatorConfigFilesPath = \"/Eventhubs_Emulator/ConfigFiles\";\n    // The path to the emulator configuration file in the container.\n    internal const string EmulatorConfigJsonFile = \"Config.json\";\n\n    private readonly AzureEventHubsResource _innerResource = innerResource ?? throw new ArgumentNullException(nameof(innerResource));\n\n    /// <inheritdoc/>\n    public override string Name => _innerResource.Name;\n\n    /// <inheritdoc />\n    public override ResourceAnnotationCollection Annotations => _innerResource.Annotations;\n}\n","sourceCodeStart":3,"sourceCodeEnd":29,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsEmulatorResource.cs#L3-L29","documentation":"AzureEventHubsEmulatorResource wraps an inner AzureEventHubsResource and stores it in a readonly field with a null guard. A null inner resource would leave the emulator resource with no Name, no annotations, and no backing configuration, so it is rejected at construction time.","triggerScenarios":"Directly constructing AzureEventHubsEmulatorResource with a null innerResource — e.g. manual construction in tests or tooling that should be using the RunAsEmulator extension instead.","commonSituations":"Unit tests instantiating the emulator resource directly; custom harness code building the resource graph by hand; refactoring that removed the original resource before creating the emulator wrapper.","solutions":["Pass the existing AzureEventHubsResource instance when constructing the emulator resource","Prefer the RunAsEmulator extension, which wires the inner resource automatically","Fix any test fixture or deserializer that fails to supply the inner resource"],"exampleFix":"// before\nvar emulator = new AzureEventHubsEmulatorResource(\"emulator\", null);\n// after\nvar emulator = new AzureEventHubsEmulatorResource(\"emulator\", eventHubsResource);","handlingStrategy":"type-guard","validationCode":"if (eventHubsResource is null) throw new ArgumentNullException(nameof(eventHubsResource));","typeGuard":"static bool CanCreateEmulatorResource(AzureEventHubsResource? inner) => inner is not null;","tryCatchPattern":"try { var emulator = new AzureEventHubsEmulatorResource(name, inner); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"innerResource\") { /* supply the real resource */ }","preventionTips":["Use RunAsEmulator instead of constructing the emulator resource directly","Keep a single reference to the underlying resource in test fixtures","Enable nullable reference types in test projects"],"tags":["eventhubs","emulator","null-argument"],"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"}