{"record":{"id":"1a0af04a66d3a106","repo":"microsoft/aspire","slug":"browser-user-data-directory-0-was-not-found","errorCode":null,"errorMessage":"Browser user data directory '{0}' was not found.","messagePattern":"Browser user data directory '(.+?)' was not found\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Browsers/ChromiumBrowserResolver.cs","lineNumber":59,"sourceCode":"            {\n                return resolvedPath;\n            }\n        }\n\n        return PathLookupHelper.FindFullPathFromPath(browser);\n    }\n\n    /// <summary>\n    /// Resolves a Chromium profile directory name from a directory name, profile display name, or shortcut name.\n    /// </summary>\n    internal static string ResolveProfileDirectory(string userDataDirectory, string profile)\n    {\n        ArgumentException.ThrowIfNullOrWhiteSpace(userDataDirectory);\n        ArgumentException.ThrowIfNullOrWhiteSpace(profile);\n\n        if (!Directory.Exists(userDataDirectory))\n        {\n            throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, BrowserMessageStrings.BrowserLogsUserDataDirectoryNotFound, userDataDirectory));\n        }\n\n        if (TryResolveProfileDirectoryFromDirectoryEntries(userDataDirectory, profile) is { } directMatch)\n        {\n            return directMatch;\n        }\n\n        // Chromium stores profile metadata in the user-data-root \"Local State\" file under profile.info_cache. Directory\n        // names like \"Default\" or \"Profile 1\" are stable command-line values, while \"name\" and \"shortcut_name\" are\n        // user-facing labels that can be renamed in the browser UI.\n        //\n        // Relevant Local State shape:\n        // {\n        //   \"profile\": {\n        //     \"info_cache\": {\n        //       \"Default\": { \"name\": \"Person 1\", \"shortcut_name\": \"Person 1\" },\n        //       \"Profile 1\": { \"name\": \"Work\", \"shortcut_name\": \"Work\" }\n        //     }","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Browsers/ChromiumBrowserResolver.cs#L41-L77","documentation":"ChromiumBrowserResolver.ResolveProfileDirectory validates that the supplied browser user data directory exists on disk before searching for a profile. If Directory.Exists(userDataDirectory) is false, it throws this InvalidOperationException naming the missing directory, because profile resolution is impossible without the user data root.","triggerScenarios":"Calling ResolveProfileDirectory with a userDataDirectory path that does not exist (typo, deleted profile, wrong OS-specific path, fresh machine where Chromium never ran).","commonSituations":"Hardcoding a Chrome user data path like ~/.config/google-chrome on Windows; pointing at a brand-new machine where the browser has never launched; user deleted or migrated the profile directory.","solutions":["Verify the user data directory path (e.g., %LOCALAPPDATA%/Google/Chrome/User Data on Windows, ~/.config/google-chrome on Linux) before resolving.","Launch the Chromium browser once so it creates its user data directory.","Confirm the correct browser product's data directory is being passed.","Pre-create or validate the directory with Directory.Exists and fail early with a clear message."],"exampleFix":"// before\nvar dir = resolver.ResolveProfileDirectory(\"/home/user/.config/chrome\", \"Default\");\n// after\nvar userData = OperatingSystem.IsWindows()\n    ? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), \"Google\", \"Chrome\", \"User Data\")\n    : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), \".config\", \"google-chrome\");\nif (!Directory.Exists(userData)) throw new DirectoryNotFoundException(userData);\nvar dir = resolver.ResolveProfileDirectory(userData, \"Default\");","handlingStrategy":"validation","validationCode":"if (!Directory.Exists(userDataDirectory))\n{\n    throw new DirectoryNotFoundException($\"Browser user data directory missing: {userDataDirectory}\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var dir = resolver.ResolveProfileDirectory(userData, profile);\n}\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Browser user data directory\"))\n{\n    logger.LogError(\"User data directory '{Dir}' not found — launch the browser once first.\", userData);\n}","preventionTips":["Resolve per-OS default user data paths instead of hardcoding them.","Check Directory.Exists before any browser profile resolution.","On fresh machines, launch the browser once to create the profile store."],"tags":["browser","chromium","filesystem","directory-not-found"],"backgroundTag":"directory-not-found","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"}