{"record":{"id":"e49efbed889df013","repo":"microsoft/aspire","slug":"the-configuration-file-mount-could-not-be-parsed-e49efb","errorCode":null,"errorMessage":"The configuration file mount could not be parsed.","messagePattern":"The configuration file mount could not be parsed\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusExtensions.cs","lineNumber":484,"sourceCode":"            {\n                var customConfigFile = builder.Resource.Annotations.OfType<ConfigFileAnnotation>().FirstOrDefault();\n                if (customConfigFile != null)\n                {\n                    return Task.FromResult<IEnumerable<ContainerFileSystemItem>>([\n                        new ContainerFile\n                        {\n                            Name = AzureServiceBusEmulatorResource.EmulatorConfigJsonFile,\n                            SourcePath = customConfigFile.SourcePath,\n                        },\n                    ]);\n                }\n\n                // Create default Config.json file content\n                var tempConfig = JsonNode.Parse(CreateEmulatorConfigJson(builder.Resource));\n\n                if (tempConfig == null)\n                {\n                    throw new InvalidOperationException(\"The configuration file mount could not be parsed.\");\n                }\n\n                // Apply ConfigJsonAnnotation modifications\n                var configJsonAnnotations = builder.Resource.Annotations.OfType<ConfigJsonAnnotation>();\n\n                if (configJsonAnnotations.Any())\n                {\n                    foreach (var annotation in configJsonAnnotations)\n                    {\n                        annotation.Configure(tempConfig);\n                    }\n                }\n\n                using var writeStream = new MemoryStream();\n                using var writer = new Utf8JsonWriter(writeStream, new JsonWriterOptions { Indented = true });\n                tempConfig.WriteTo(writer);\n\n                writer.Flush();","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusExtensions.cs#L466-L502","documentation":"When RunAsEmulator builds the emulator's Config.json, it parses the generated JSON with JsonNode.Parse and throws InvalidOperationException if the result is null (i.e. the string represented only JSON null or whitespace). This is an internal invariant: CreateEmulatorConfigJson should always produce a parseable object, so a null parse means the mount content could not be produced.","triggerScenarios":"Calling RunAsEmulator when JsonNode.Parse(CreateEmulatorConfigJson(builder.Resource)) returns null — the generated default config string is effectively empty or the literal null.","commonSituations":"Modified or broken custom config generation (e.g. extensions/hooks that overwrite the config source); corrupted package install where the template content is missing; very rare framework bug.","solutions":["Update Aspire.Hosting.Azure.ServiceBus to the latest version, since this indicates the generated config template is broken.","Check whether any WithConfigJson-like annotations or custom code altered the configuration pipeline and remove the interference.","Rebuild/clean your AppHost and re-restore packages to repair a corrupted install.","If reproducible, file an issue with the AppHost code that triggers it — this exception is not expected in normal use."],"exampleFix":"// before (suspected custom mutation corrupting config)\nsb.RunAsEmulator(e => e.WithConfigJson(\"null\"));\n// after\nsb.RunAsEmulator(e => e.WithConfigJson(configBuilder => { /* valid JSON object */ }));","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    sb.RunAsEmulator();\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"configuration file mount could not be parsed\"))\n{\n    // remove custom config mutations / WithConfigJson annotations, or update package, then retry\n}","preventionTips":["Keep custom emulator config JSON a valid object (never \"null\" or empty).","Update Aspire.Hosting.Azure.ServiceBus if this fires — the generated template should always parse.","Remove conflicting ConfigJson annotations/hooks when debugging this error.","Clean/rebuild to rule out corrupted package content."],"tags":["azure","servicebus","emulator","json"],"backgroundTag":"json-parse-error","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"}