{"record":{"id":"8e1d79efebc74deb","repo":"microsoft/aspire","slug":"browser-profile-0-matched-multiple-chromium-profiles-under-1","errorCode":null,"errorMessage":"Browser profile '{0}' matched multiple Chromium profiles under '{1}'. Specify the profile directory name instead.","messagePattern":"Browser profile '(.+?)' matched multiple Chromium profiles under '(.+?)'\\. Specify the profile directory name instead\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Browsers/ChromiumBrowserResolver.cs","lineNumber":146,"sourceCode":"            return null;\n        }\n\n        string? match = null;\n\n        foreach (var profileEntry in infoCacheElement.EnumerateObject())\n        {\n            // Ignore stale metadata entries whose profile directories no longer exist.\n            if (!Directory.Exists(Path.Combine(userDataDirectory, profileEntry.Name)) ||\n                !MatchesBrowserProfile(profileEntry, profile))\n            {\n                continue;\n            }\n\n            // Profile display names are not unique. Force the caller to use the stable directory name when ambiguity\n            // would otherwise select an arbitrary profile.\n            if (match is not null && !string.Equals(match, profileEntry.Name, StringComparison.Ordinal))\n            {\n                throw new InvalidOperationException(\n                    string.Format(CultureInfo.CurrentCulture, BrowserMessageStrings.BrowserLogsAmbiguousProfile, profile, userDataDirectory));\n            }\n\n            match = profileEntry.Name;\n        }\n\n        return match;\n    }\n\n    internal static IReadOnlyList<ChromiumBrowserProfile> GetAvailableProfiles(string userDataDirectory)\n    {\n        ArgumentException.ThrowIfNullOrWhiteSpace(userDataDirectory);\n\n        if (!Directory.Exists(userDataDirectory))\n        {\n            return [];\n        }\n","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Browsers/ChromiumBrowserResolver.cs#L128-L164","documentation":"TryResolveProfileDirectory throws this when the given profile value matches a profile display name that maps to more than one profile directory under the user data directory. Because Chromium display names are not unique, the library refuses to pick arbitrarily and demands the stable directory name instead.","triggerScenarios":"Calling ResolveProfileDirectory with a display name (from Local State's profile metadata) that two or more profile directories share; the code path detects match != profileEntry.Name for multiple entries.","commonSituations":"Two Chrome profiles both named 'Work' or 'Personal' (common after profile duplication); users renaming profiles to identical labels; automated tooling resolving profiles by human-readable name.","solutions":["Pass the profile's directory name (e.g., 'Profile 1', 'Default') instead of its display name.","Find the directory name via chrome://version (Profile Path) or by inspecting Local State's info_cache.","Rename one of the duplicate profiles in Chrome to make display names unique.","Catch this exception and prompt the user to disambiguate by directory name."],"exampleFix":"// before\nvar dir = resolver.ResolveProfileDirectory(userData, \"Work\"); // two profiles named 'Work'\n// after\nvar dir = resolver.ResolveProfileDirectory(userData, \"Profile 2\"); // stable directory name","handlingStrategy":"validation","validationCode":"var matchingDirs = Directory.GetDirectories(userDataDirectory)\n    .Where(d => !Path.GetFileName(d).Equals(profile, StringComparison.Ordinal))\n    .Where(d => IsDisplayName(d, profile)) // via Local State metadata\n    .ToList();\nif (matchingDirs.Count > 1)\n{\n    throw new ArgumentException($\"'{profile}' is ambiguous; use a directory name instead.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var dir = resolver.ResolveProfileDirectory(userData, profile);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"matched multiple\"))\n{\n    // ask the user which directory-backed profile to use\n}","preventionTips":["Always resolve by directory name ('Default', 'Profile 1'), never display name.","Rename duplicate Chrome profile labels to keep display names unique.","Read Local State's info_cache to map display names to unique directory names up front."],"tags":["browser","chromium","profile","ambiguity"],"backgroundTag":"ambiguous-match","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"}