{"record":{"id":"317a688254554f8c","repo":"microsoft/aspire","slug":"browsermessagestrings","errorCode":null,"errorMessage":"BrowserMessageStrings.BrowserLogsProfileRequiresSharedUserDataMode","messagePattern":"BrowserMessageStrings\\.BrowserLogsProfileRequiresSharedUserDataMode","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Browsers/BrowserConfiguration.cs","lineNumber":67,"sourceCode":"        // 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.\n        var appHostKey = configuration[\"AppHost:PathSha256\"];\n\n        return new BrowserConfiguration(resolvedBrowser, resolvedProfile, resolvedUserDataMode, appHostKey);\n    }\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Browsers/BrowserConfiguration.cs#L49-L85","documentation":"The 'Isolated' user-data mode launches the browser with a fresh, throwaway user-data directory, which is fundamentally incompatible with a named profile: a profile implies a persistent, shared user-data root. When Resolve sees UserDataMode.Isolated together with a non-null profile, it throws using the localized string BrowserLogsProfileRequiresSharedUserDataMode, listing the offending profile and the relevant configuration keys.","triggerScenarios":"Calling WithBrowserLogs with both a profile entry (ProfileConfigurationKey set) and userdata mode 'Isolated' (UserDataModeConfigurationKey = \"Isolated\"), whether both come from explicit values or from a mix of config layers.","commonSituations":"Combining a team-shared profile config with an isolated-mode default set elsewhere; trying to sandbox a named profile believing Isolated gives extra isolation; merging snippets where one sets profile and another sets isolated mode.","solutions":["Change the user-data mode to 'Shared' when a profile is specified: UserDataModeConfigurationKey = \"Shared\".","Or remove the profile entry to keep Isolated mode with a throwaway user-data directory.","Audit all configuration layers (explicit, resource-level, global) for conflicting keys from different sources.","If you need isolation per run, drop the named profile and rely on Isolated alone."],"exampleFix":"// before\n.WithBrowserLogs(new Dictionary<string, string?> {\n    [\"profile\"] = \"work\",\n    [\"userdatamode\"] = \"Isolated\" // conflicts with profile\n})\n\n// after\n.WithBrowserLogs(new Dictionary<string, string?> {\n    [\"profile\"] = \"work\",\n    [\"userdatamode\"] = \"Shared\"\n})","handlingStrategy":"validation","validationCode":"var profile = config[\"profile\"];\nvar mode = config[\"userdatamode\"];\nif (profile is { } && string.Equals(mode, \"Isolated\", StringComparison.OrdinalIgnoreCase))\n    throw new ArgumentException(\"Profile requires userdatamode=Shared.\");","typeGuard":null,"tryCatchPattern":"try { BrowserConfiguration.Resolve(...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Shared\"))\n{ logger.LogError(ex, \"Profile and Isolated user-data mode are mutually exclusive\"); throw; }","preventionTips":["Treat profile + Isolated as mutually exclusive in any config templating.","Centralize browser-logs config in one place instead of merging snippets from multiple layers.","Prefer Shared mode whenever a named profile is required."],"tags":["browser","configuration","conflicting-options","browser-logs"],"backgroundTag":"conflicting-config-options","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"}