microsoft/aspire · error · InvalidOperationException
BrowserMessageStrings.BrowserLogsEmptyProfileConfiguration
Error message
BrowserMessageStrings.BrowserLogsEmptyProfileConfiguration
What it means
During browser-logs configuration resolution, the 'profile' value, when explicitly provided, must be non-whitespace. Resolve detects a present-but-empty profile (resolvedProfile is not null but whitespace) and throws using the localized string BrowserLogsEmptyProfileConfiguration, because an empty profile name cannot identify a persistent browser user-data profile.
Solutions
- Provide a real profile name, e.g. profile = "my-debug-profile", or remove the profile key entirely to use the default profile.
- Check the environment variable/config source is omitted (not set to empty) when the profile is not needed.
- Trim and validate the profile value before passing it into the browser-logs builder.
- Review template substitution that may inject empty strings for missing variables.
Example fix
// before
["profile"] = Environment.GetEnvironmentVariable("BROWSER_PROFILE") ?? "" // empty when unset
// after
var profile = Environment.GetEnvironmentVariable("BROWSER_PROFILE");
var config = string.IsNullOrWhiteSpace(profile)
? new Dictionary<string, string?>() // omit key entirely
: new Dictionary<string, string?> { ["profile"] = profile }; Defensive patterns
Strategy: validation
Validate before calling
var profile = config["profile"];
if (profile is not null && string.IsNullOrWhiteSpace(profile))
throw new ArgumentException("Profile, when set, must be non-empty. Omit the key to use the default."); Try / catch
try { BrowserConfiguration.Resolve(...); }
catch (InvalidOperationException ex) when (ex.Message.Contains("profile configuration"))
{ logger.LogError(ex, "Profile key set to empty; provide a name or omit it"); throw; } Prevention
- Omit the profile key instead of assigning an empty string.
- Guard environment-variable substitution so unset variables drop the key.
- Trim user-supplied profile names before wiring config.
When it happens
Trigger: Passing a ProfileConfigurationKey entry with an empty/whitespace string value into WithBrowserLogs, or setting the profile key via configuration (env var/app config) to "" or spaces.
Common situations: YAML/env templating where an unset variable resolves to an empty string instead of being omitted; copy-paste of profile config with the value left blank; downstream tooling writing empty values for optional keys.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- BrowserMessageStrings.BrowserLogsProfileRequiresSharedUserDa…
- BrowserMessageStrings.BrowserLogsEmptyBrowserConfiguration
- Browser profile ' ' matched multiple Chromium profiles…
- Browser profile ' ' was not found under ' '. Specify the…
- BrowserMessageStrings.BrowserLogsInvalidUserDataModeConfigur…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/e1e4abfd304446e3.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Browsers/BrowserConfiguration.cs:62
var browserLogsSection = configuration.GetSection(BrowserLogsBuilderExtensions.BrowserLogsConfigurationSectionName);
var resourceSection = browserLogsSection.GetSection(resourceName);
// Resolution order is explicit argument -> resource-specific config -> global browser-log config -> default.
// Resolve user-data mode before browser so the browser default can prefer Edge for shared state and Chrome for
// disposable isolated state.
var resolvedProfile = ResolveProfile(explicitValues, resourceRuntimeConfiguration, globalRuntimeConfiguration, resourceSection, browserLogsSection);
var resolvedUserDataMode = ResolveUserDataMode(explicitValues, resourceRuntimeConfiguration, globalRuntimeConfiguration, resourceSection, browserLogsSection);
var resolvedBrowser = ResolveBrowser(explicitValues, resourceRuntimeConfiguration, globalRuntimeConfiguration, resourceSection, browserLogsSection, resolvedUserDataMode);
if (string.IsNullOrWhiteSpace(resolvedBrowser))
{
throw new InvalidOperationException(BrowserMessageStrings.BrowserLogsEmptyBrowserConfiguration);
}
if (resolvedProfile is not null && string.IsNullOrWhiteSpace(resolvedProfile))
{
throw new InvalidOperationException(BrowserMessageStrings.BrowserLogsEmptyProfileConfiguration);
}
if (resolvedUserDataMode == BrowserUserDataMode.Isolated && resolvedProfile is not null)
{
throw new InvalidOperationException(
string.Format(
CultureInfo.CurrentCulture,
BrowserMessageStrings.BrowserLogsProfileRequiresSharedUserDataMode,
BrowserLogsBuilderExtensions.ProfileConfigurationKey,
resolvedProfile,
BrowserLogsBuilderExtensions.UserDataModeConfigurationKey,
BrowserUserDataMode.Isolated,
BrowserUserDataMode.Shared));
}
// Stable per-AppHost key sourced from DistributedApplicationBuilder. Only Isolated mode actually needs it
// (its user-data path includes the AppHost segment), but it is always captured here so the registry never
// has to re-read configuration. The same SHA value is used for other per-AppHost persisted state.View on GitHub (pinned to 25830f84bd)