{"record":{"id":"e1e4abfd304446e3","repo":"microsoft/aspire","slug":"browsermessagestrings-browserlogsemptyprofileconfiguration","errorCode":null,"errorMessage":"BrowserMessageStrings.BrowserLogsEmptyProfileConfiguration","messagePattern":"BrowserMessageStrings\\.BrowserLogsEmptyProfileConfiguration","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Browsers/BrowserConfiguration.cs","lineNumber":62,"sourceCode":"\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));\n        }\n\n        // Stable per-AppHost key sourced from DistributedApplicationBuilder. Only Isolated mode actually needs it\n        // (its user-data path includes the AppHost segment), but it is always captured here so the registry never\n        // has to re-read configuration. The same SHA value is used for other per-AppHost persisted state.","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Browsers/BrowserConfiguration.cs#L44-L80","documentation":"During browser-logs configuration resolution, the 'profile' value, when explicitly provided, must be non-whitespace. Resolve detects a present-but-empty profile (resolvedProfile is not null but whitespace) and throws using the localized string BrowserLogsEmptyProfileConfiguration, because an empty profile name cannot identify a persistent browser user-data profile.","triggerScenarios":"Passing a ProfileConfigurationKey entry with an empty/whitespace string value into WithBrowserLogs, or setting the profile key via configuration (env var/app config) to \"\" or spaces.","commonSituations":"YAML/env templating where an unset variable resolves to an empty string instead of being omitted; copy-paste of profile config with the value left blank; downstream tooling writing empty values for optional keys.","solutions":["Provide a real profile name, e.g. profile = \"my-debug-profile\", or remove the profile key entirely to use the default profile.","Check the environment variable/config source is omitted (not set to empty) when the profile is not needed.","Trim and validate the profile value before passing it into the browser-logs builder.","Review template substitution that may inject empty strings for missing variables."],"exampleFix":"// before\n[\"profile\"] = Environment.GetEnvironmentVariable(\"BROWSER_PROFILE\") ?? \"\" // empty when unset\n\n// after\nvar profile = Environment.GetEnvironmentVariable(\"BROWSER_PROFILE\");\nvar config = string.IsNullOrWhiteSpace(profile)\n    ? new Dictionary<string, string?>() // omit key entirely\n    : new Dictionary<string, string?> { [\"profile\"] = profile };","handlingStrategy":"validation","validationCode":"var profile = config[\"profile\"];\nif (profile is not null && string.IsNullOrWhiteSpace(profile))\n    throw new ArgumentException(\"Profile, when set, must be non-empty. Omit the key to use the default.\");","typeGuard":null,"tryCatchPattern":"try { BrowserConfiguration.Resolve(...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"profile configuration\"))\n{ logger.LogError(ex, \"Profile key set to empty; provide a name or omit it\"); throw; }","preventionTips":["Omit the profile key instead of assigning an empty string.","Guard environment-variable substitution so unset variables drop the key.","Trim user-supplied profile names before wiring config."],"tags":["browser","configuration","profile","browser-logs"],"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"}