{"record":{"id":"58113924f5dc28b3","repo":"microsoft/aspire","slug":"browsermessagestrings-browserlogsemptybrowserconfiguration","errorCode":null,"errorMessage":"BrowserMessageStrings.BrowserLogsEmptyBrowserConfiguration","messagePattern":"BrowserMessageStrings\\.BrowserLogsEmptyBrowserConfiguration","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Browsers/BrowserConfiguration.cs","lineNumber":57,"sourceCode":"        BrowserConfiguration? resourceRuntimeConfiguration = null,\n        BrowserConfiguration? globalRuntimeConfiguration = null)\n    {\n        ArgumentNullException.ThrowIfNull(configuration);\n        ArgumentException.ThrowIfNullOrWhiteSpace(resourceName);\n\n        var browserLogsSection = configuration.GetSection(BrowserLogsBuilderExtensions.BrowserLogsConfigurationSectionName);\n        var resourceSection = browserLogsSection.GetSection(resourceName);\n\n        // Resolution order is explicit argument -> resource-specific config -> global browser-log config -> default.\n        // Resolve user-data mode before browser so the browser default can prefer Edge for shared state and Chrome for\n        // disposable isolated state.\n        var resolvedProfile = ResolveProfile(explicitValues, resourceRuntimeConfiguration, globalRuntimeConfiguration, resourceSection, browserLogsSection);\n        var resolvedUserDataMode = ResolveUserDataMode(explicitValues, resourceRuntimeConfiguration, globalRuntimeConfiguration, resourceSection, browserLogsSection);\n        var resolvedBrowser = ResolveBrowser(explicitValues, resourceRuntimeConfiguration, globalRuntimeConfiguration, resourceSection, browserLogsSection, resolvedUserDataMode);\n\n        if (string.IsNullOrWhiteSpace(resolvedBrowser))\n        {\n            throw new InvalidOperationException(BrowserMessageStrings.BrowserLogsEmptyBrowserConfiguration);\n        }\n\n        if (resolvedProfile is not null && string.IsNullOrWhiteSpace(resolvedProfile))\n        {\n            throw new InvalidOperationException(BrowserMessageStrings.BrowserLogsEmptyProfileConfiguration);\n        }\n\n        if (resolvedUserDataMode == BrowserUserDataMode.Isolated && resolvedProfile is not null)\n        {\n            throw new InvalidOperationException(\n                string.Format(\n                    CultureInfo.CurrentCulture,\n                    BrowserMessageStrings.BrowserLogsProfileRequiresSharedUserDataMode,\n                    BrowserLogsBuilderExtensions.ProfileConfigurationKey,\n                    resolvedProfile,\n                    BrowserLogsBuilderExtensions.UserDataModeConfigurationKey,\n                    BrowserUserDataMode.Isolated,\n                    BrowserUserDataMode.Shared));","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Browsers/BrowserConfiguration.cs#L39-L75","documentation":"When resolving the effective browser configuration for browser-logs capture, the 'browser' value must be non-empty. Resolve merges explicit values, resource-level, and global configuration; if the merged browser name is null/whitespace, the configuration cannot name a browser to launch and this InvalidOperationException is thrown using the localized resource string BrowserLogsEmptyBrowserConfiguration.","triggerScenarios":"Calling WithBrowserLogs / the BrowserConfiguration.Resolve path with an explicit BrowserLogs configuration where the browser key is set to an empty string, or no default browser is configured anywhere (explicit values, resource runtime config, and global runtime config all empty).","commonSituations":"Setting BrowserLogsBuilderExtensions.BrowserConfigurationKey to \"\" accidentally; clearing config via environment variables with empty values overriding defaults; forgetting to configure any browser while opting into browser logs capture.","solutions":["Set a browser name in the browser-logs configuration, e.g. WithBrowser(\"chrome\") or the equivalent config key.","Check environment variables/config sources are not overriding the browser key with an empty value.","Remove the explicit empty browser entry so the global default applies.","Inspect resolved configuration layers (explicit > resource > global) to find the layer producing the empty value."],"exampleFix":"// before\n.WithBrowserLogs(new Dictionary<string, string?> { [\"browser\"] = \"\" })\n\n// after\n.WithBrowserLogs(new Dictionary<string, string?> { [\"browser\"] = \"chrome\" })","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(config[\"browser\"]))\n    throw new ArgumentException(\"Browser must be a non-empty name (e.g. 'chrome').\");","typeGuard":null,"tryCatchPattern":"try { BrowserConfiguration.Resolve(...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"browser configuration\"))\n{ logger.LogError(ex, \"Set a non-empty browser value in the browser-logs config\"); throw; }","preventionTips":["Always set an explicit browser name when opting into browser logs.","Check env vars don't override config keys with empty strings.","Omit optional keys rather than setting them to empty."],"tags":["browser","configuration","browser-logs","empty-value"],"backgroundTag":"empty-required-field","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"}