EpicGames/lore · error
Invalid user_agent_patterns
Error message
Invalid user_agent_patterns: {e} What it means
async_main builds a UserAgentFilter from settings.server.user_agent.user_agent_patterns. UserAgentFilter::new compiles these patterns; any invalid pattern returns an error which is re-wrapped as this message, aborting server startup.
Solutions
- Validate each pattern with the same regex/pattern engine UserAgentFilter uses (e.g. test with `regex::Regex::new`)
- Fix or remove the offending pattern in [server.user_agent] user_agent_patterns
- Add a config pre-check/lint step that compiles all patterns before deployment
Example fix
# before [server.user_agent] user_agent_patterns = ["^Mozilla.*[", "curl"] # after [server.user_agent] user_agent_patterns = ["^Mozilla.*", "curl"]
Defensive patterns
Strategy: validation
Validate before calling
for pat in &settings.server.user_agent.user_agent_patterns {
if let Err(e) = regex::Regex::new(pat) {
return Err(format!("invalid user_agent_pattern '{pat}': {e}"));
}
} Type guard
fn valid_patterns(pats: &[String]) -> bool {
pats.iter().all(|p| regex::Regex::new(p).is_ok())
} Try / catch
let user_agent_filter = match UserAgentFilter::new(&ua.user_agent_patterns) {
Ok(f) => Arc::new(f.with_unknown_sample_rate(ua.unknown_user_agent_sample_rate)),
Err(e) => { eprintln!("Invalid user_agent_patterns: {e}"); std::process::exit(2); }
}; Prevention
- Test every user-agent pattern against the regex engine before committing config
- Add a config lint step that compiles all patterns in CI
- Escape regex metacharacters when interpolating env vars into patterns
When it happens
Trigger: A user_agent_patterns entry in [server.user_agent] is not a valid pattern for the UserAgentFilter parser (malformed regex/wildcard syntax), so UserAgentFilter::new fails and the map_err produces this error.
Common situations: Hand-written regex with unbalanced brackets or invalid escapes in the TOML; copying patterns between filter implementations with different syntax; environment-variable overrides injecting unescaped special characters.
Related errors
- [environment.endpoint] auth_url is set but [server.auth] is…
- [environment.endpoint] auth_url and [server.auth]…
- Missing gRPC settings
- Missing gRPC internal settings
- Missing local immutable store settings
AI-assisted analysis of EpicGames/lore@074eb0b0d1 (2026-09-13).
Data as JSON: /api/errors/6341fbf37fd3052e.
Report an issue: GitHub.
Appendix: source
Thrown at lore-server/src/server.rs:1677
.inner
.map(|provider| provider.detectors(runtime_handle.clone()))
.unwrap_or_default();
detectors.extend(self.registry.resource_detectors(runtime_handle));
detectors
}
}
async fn async_main(settings: (Settings, StringHash), config: ServerConfig) -> Result<()> {
// Initialize metrics and tracing telemetry, returns a guard that will cleanup when it falls out
// of scope
let (settings, settings_hash) = settings;
let runtime = runtime();
let telemetry = settings.telemetry.clone().unwrap_or_default();
let metrics_config = telemetry.metrics.clone().unwrap_or_default();
let ua = &settings.server.user_agent;
let user_agent_filter = Arc::new(
UserAgentFilter::new(&ua.user_agent_patterns)
.map_err(|e| anyhow::anyhow!("Invalid user_agent_patterns: {e}"))?
.with_unknown_sample_rate(ua.unknown_user_agent_sample_rate),
);
// Initialize the plugin registry before telemetry: start with the
// pre-populated registry from config, then register any build.rs-discovered
// plugins. This must happen first so that every compiled-in plugin can
// contribute OpenTelemetry resource detectors describing the deployment
// environment it implies (e.g. AWS region, Nomad allocation).
let mut plugin_registry = config.plugin_registry;
plugins::register_all_plugins(&mut plugin_registry);
let _guard = {
let resource_detector_provider = PluginResourceDetectorProvider {
inner: config.resource_detector_provider.as_deref(),
registry: &plugin_registry,
};
TelemetryInitializer::from_config(
&telemetry,View on GitHub (pinned to 074eb0b0d1)