{"record":{"id":"08b5a388df21589b","repo":"microsoft/aspire","slug":"sourcepath","errorCode":null,"errorMessage":"sourcePath","messagePattern":"sourcePath","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.ServiceBus/ConfigFileAnnotation.cs","lineNumber":15,"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.ServiceBus;\n\n/// <summary>\n/// Represents an annotation for a custom config file source.\n/// </summary>\ninternal sealed class ConfigFileAnnotation : IResourceAnnotation\n{\n    public ConfigFileAnnotation(string sourcePath)\n    {\n        SourcePath = sourcePath ?? throw new ArgumentNullException(nameof(sourcePath));\n    }\n\n    public string SourcePath { get; }\n}\n","sourceCodeStart":1,"sourceCodeEnd":20,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.ServiceBus/ConfigFileAnnotation.cs#L1-L20","documentation":"ConfigFileAnnotation throws ArgumentNullException when constructed with a null sourcePath. This internal annotation records the path of a custom config file to attach to a resource, and a null path would make the annotation meaningless.","triggerScenarios":"Constructing ConfigFileAnnotation with a null string, typically from a helper that resolves a file path which failed to resolve.","commonSituations":"Path resolution helpers returning null when the config file does not exist or an environment variable used in the path is unset.","solutions":["Pass a non-empty, verified file path to the constructor.","Resolve the path with an absolute base before construction and fail earlier with a clearer message if missing.","Check the upstream path expression for null (e.g. Environment.GetEnvironmentVariable result) before creating the annotation."],"exampleFix":"// before\nvar annotation = new ConfigFileAnnotation(Environment.GetEnvironmentVariable(\"MY_CONFIG\"));\n\n// after\nvar path = Environment.GetEnvironmentVariable(\"MY_CONFIG\") ?? throw new InvalidOperationException(\"MY_CONFIG is not set.\");\nvar annotation = new ConfigFileAnnotation(path);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(sourcePath)) throw new InvalidOperationException(\"Config file path must be a non-empty path.\");","typeGuard":"if (sourcePath is not null) { new ConfigFileAnnotation(sourcePath); }","tryCatchPattern":null,"preventionTips":["Resolve environment-based paths with explicit null/empty fallbacks.","Verify the file exists (File.Exists) before annotating.","Use Path.Combine with a known base directory instead of raw env vars."],"tags":["argument-null","annotation","config"],"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"}