{"record":{"id":"fecff9d4909a831e","repo":"microsoft/aspire","slug":"value-cannot-be-null-parameter-innerresource-fecff9","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'innerResource')","messagePattern":"Value cannot be null\\. \\(Parameter 'innerResource'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Kusto/AzureKustoEmulatorResource.cs","lineNumber":18,"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/// A resource that represents a Kusto emulator running as a container.\n/// </summary>\npublic class AzureKustoEmulatorResource : ContainerResource\n{\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"AzureKustoEmulatorResource\"/> class.\n    /// </summary>\n    /// <param name=\"innerResource\">The wrapped Kusto resource.</param>\n    public AzureKustoEmulatorResource(AzureKustoClusterResource innerResource)\n        : base(innerResource?.Name ?? throw new ArgumentNullException(nameof(innerResource)))\n    {\n        InnerResource = innerResource;\n    }\n\n    /// <inheritdoc />\n    public override ResourceAnnotationCollection Annotations => InnerResource.Annotations;\n\n    /// <summary>\n    /// Gets the wrapped Kusto resource.\n    /// </summary>\n    internal AzureKustoClusterResource InnerResource { get; }\n}\n","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Kusto/AzureKustoEmulatorResource.cs#L1-L31","documentation":"AzureKustoEmulatorResource is a wrapper (projection) around an AzureKustoClusterResource. Its constructor requires the wrapped inner resource; passing null throws ArgumentNullException because the wrapper needs the inner resource's name and annotations.","triggerScenarios":"Constructing new AzureKustoEmulatorResource(null) — either directly or via extension code that passes an unbuilt/unresolved cluster resource.","commonSituations":"Custom extensions or tests creating emulator wrapper resources before the cluster resource has been constructed, or a factory returning null instead of the cluster resource.","solutions":["Pass a valid, non-null AzureKustoClusterResource instance to the constructor.","Ensure the code path creating the emulator wrapper runs after AddAzureKustoCluster has produced the resource.","Guard the call site with a null check and a clear error before constructing the wrapper.","Fix factory methods that can return null so they always return the built resource."],"exampleFix":"// before\nvar emulator = new AzureKustoEmulatorResource(GetClusterMaybe());\n// after\nvar inner = GetClusterMaybe() ?? throw new InvalidOperationException(\"Kusto cluster resource must be created before RunAsEmulator.\");\nvar emulator = new AzureKustoEmulatorResource(inner);","handlingStrategy":"type-guard","validationCode":"if (innerResource is null) throw new InvalidOperationException(\"Cluster resource must be built (AddAzureKustoCluster) before creating the emulator wrapper.\");","typeGuard":"AzureKustoEmulatorResource? TryCreate(AzureKustoClusterResource? r) => r is null ? null : new AzureKustoEmulatorResource(r);","tryCatchPattern":"try { var emulator = new AzureKustoEmulatorResource(inner); }\ncatch (ArgumentNullException) { /* innerResource was null; build the cluster resource first */ }","preventionTips":["Always construct the cluster resource via AddAzureKustoCluster before wrapping it.","Never pass nullable factory results directly into the constructor.","In tests, assert the inner resource is non-null before creating wrappers.","Keep RunAsEmulator usage on the builder rather than constructing wrapper resources manually."],"tags":["aspire","azure-kusto","null-argument","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-21T04:17:39.646Z"}