microsoft/aspire · error · InvalidOperationException

Browser profile ' ' was not found under ' '. Specify the…

Error message

Browser profile '{0}' was not found under '{1}'. Specify the profile directory name (for example 'Default' or 'Profile 1') or a browser profile name from Chromium's profile metadata.

What it means

After checking both a direct directory-name match and Chromium's profile metadata, ResolveProfileDirectory throws this if no profile directory matching the requested name/display name was found under the user data directory. The message advises using the profile directory name ('Default', 'Profile 1') or a display name from Chromium metadata.

Solutions

  1. List subdirectories under the user data directory and use the exact directory name (e.g., 'Default', 'Profile 1').
  2. Open chrome://version or Chrome's profile picker to find the correct profile identifier.
  3. Fix typos/casing in the profile argument (directory-name matching is ordinal).
  4. Create the desired profile in the browser before referencing it.

Example fix

// before
var dir = resolver.ResolveProfileDirectory(userData, "work account");
// after
// 'Profile 1' is the actual directory Chromium created
var dir = resolver.ResolveProfileDirectory(userData, "Profile 1");
Defensive patterns

Strategy: validation

Validate before calling

var candidates = Directory.GetDirectories(userDataDirectory)
    .Where(d => Path.GetFileName(d).Equals(profile, StringComparison.Ordinal))
    .ToList();
if (candidates.Count == 0)
{
    throw new ArgumentException($"Profile '{profile}' not found. Available: {string.Join(", ", Directory.GetDirectories(userDataDirectory).Select(Path.GetFileName))}");
}

Try / catch

try
{
    var dir = resolver.ResolveProfileDirectory(userData, profile);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("was not found under"))
{
    // list available profiles and re-prompt the user
}

Prevention

When it happens

Trigger: Calling ResolveProfileDirectory with a profile value that matches neither any subdirectory name nor any info_cache entry in Local State under userDataDirectory.

Common situations: Typing a friendly profile label that was never created; referencing a profile on a machine where it doesn't exist; assuming 'Profile 0' numbering when Chromium uses 'Profile 1', 'Profile 2', etc.; case/format mistakes in the directory name.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/762e5f3a5dc025ae. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.Browsers/ChromiumBrowserResolver.cs:112

                throw new InvalidOperationException(
                    string.Format(CultureInfo.CurrentCulture, BrowserMessageStrings.BrowserLogsUnableToReadProfileMetadata, localStatePath, profile),
                    ex);
            }
            catch (UnauthorizedAccessException ex)
            {
                throw new InvalidOperationException(
                    string.Format(CultureInfo.CurrentCulture, BrowserMessageStrings.BrowserLogsUnableToReadProfileMetadata, localStatePath, profile),
                    ex);
            }
            catch (JsonException ex)
            {
                throw new InvalidOperationException(
                    string.Format(CultureInfo.CurrentCulture, BrowserMessageStrings.BrowserLogsInvalidProfileMetadata, localStatePath, profile),
                    ex);
            }
        }

        throw new InvalidOperationException(
            string.Format(CultureInfo.CurrentCulture, BrowserMessageStrings.BrowserLogsProfileNotFound, profile, userDataDirectory));
    }

    /// <summary>
    /// Resolves a profile directory from Chromium's parsed Local State metadata.
    /// </summary>
    internal static string? TryResolveProfileDirectory(JsonElement localStateRoot, string userDataDirectory, string profile)
    {
        ArgumentException.ThrowIfNullOrWhiteSpace(userDataDirectory);
        ArgumentException.ThrowIfNullOrWhiteSpace(profile);

        if (!localStateRoot.TryGetProperty("profile", out var profileElement) ||
            !profileElement.TryGetProperty("info_cache", out var infoCacheElement) ||
            infoCacheElement.ValueKind != JsonValueKind.Object)
        {
            return null;
        }

View on GitHub (pinned to 25830f84bd)