{"record":{"id":"9cb393cfb78e6aa2","repo":"microsoft/aspire","slug":"unable-to-read-chromium-profile-metadata-from-0-while","errorCode":null,"errorMessage":"Unable to read Chromium profile metadata from '{0}' while resolving browser profile '{1}'.","messagePattern":"Unable to read Chromium profile metadata from '(.+?)' while resolving browser profile '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Browsers/ChromiumBrowserResolver.cs","lineNumber":94,"sourceCode":"        //       \"Profile 1\": { \"name\": \"Work\", \"shortcut_name\": \"Work\" }\n        //     }\n        //   }\n        // }\n        var localStatePath = Path.Combine(userDataDirectory, \"Local State\");\n        if (File.Exists(localStatePath))\n        {\n            try\n            {\n                using var localStateStream = File.OpenRead(localStatePath);\n                using var localStateDocument = JsonDocument.Parse(localStateStream);\n                if (TryResolveProfileDirectory(localStateDocument.RootElement, userDataDirectory, profile) is { } profileDirectory)\n                {\n                    return profileDirectory;\n                }\n            }\n            catch (IOException ex)\n            {\n                throw new InvalidOperationException(\n                    string.Format(CultureInfo.CurrentCulture, BrowserMessageStrings.BrowserLogsUnableToReadProfileMetadata, localStatePath, profile),\n                    ex);\n            }\n            catch (UnauthorizedAccessException ex)\n            {\n                throw new InvalidOperationException(\n                    string.Format(CultureInfo.CurrentCulture, BrowserMessageStrings.BrowserLogsUnableToReadProfileMetadata, localStatePath, profile),\n                    ex);\n            }\n            catch (JsonException ex)\n            {\n                throw new InvalidOperationException(\n                    string.Format(CultureInfo.CurrentCulture, BrowserMessageStrings.BrowserLogsInvalidProfileMetadata, localStatePath, profile),\n                    ex);\n            }\n        }\n\n        throw new InvalidOperationException(","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Browsers/ChromiumBrowserResolver.cs#L76-L112","documentation":"When parsing Chromium's 'Local State' metadata file to resolve a profile, an IOException while reading the file is wrapped in this InvalidOperationException (with localStatePath and profile interpolated). The library treats an unreadable metadata file as a resolution failure rather than silently ignoring the profile.","triggerScenarios":"ResolveProfileDirectory attempts to read <userDataDirectory>/Local State and the underlying file read throws IOException — e.g., disk error, file locked by a running browser, or the path is a directory.","commonSituations":"Chrome is running and holds the Local State file with conflicting locks; the profile directory was partially copied/synced; antivirus or backup software temporarily locks the file; disk/network drive issues.","solutions":["Close all running Chromium/Chrome instances so the Local State file is not locked, then retry.","Retry after a short delay if the file was transiently locked (AV scan, sync tool).","Verify the user data directory is a complete, healthy Chrome profile copy.","Catch this exception and fall back to specifying the profile by directory name without metadata lookup."],"exampleFix":"// before\nvar dir = resolver.ResolveProfileDirectory(userData, \"Work\");\n// after\ntry\n{\n    var dir = resolver.ResolveProfileDirectory(userData, \"Work\");\n}\ncatch (InvalidOperationException) when (chromeIsRunning)\n{\n    // prompt user to close Chrome and retry\n}","handlingStrategy":"retry","validationCode":"// Ensure no Chromium processes hold the metadata file\nvar chromeRunning = Process.GetProcessesByName(\"chrome\").Length > 0;\nif (chromeRunning) { /* prompt to close or use a copy */ }","typeGuard":null,"tryCatchPattern":"try\n{\n    var dir = resolver.ResolveProfileDirectory(userData, profile);\n}\ncatch (InvalidOperationException ex) when (ex.InnerException is IOException)\n{\n    await Task.Delay(500);\n    // retry once, else fall back to directory-name resolution\n}","preventionTips":["Close running Chromium instances before resolving profiles.","Exclude the profile directory from AV/backup locks during resolution.","Work on a complete copy of the profile rather than the live one."],"tags":["browser","chromium","file-read","io"],"backgroundTag":"file-read-failed","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"}