{"record":{"id":"6341fbf37fd3052e","repo":"EpicGames/lore","slug":"invalid-user-agent-patterns-e","errorCode":null,"errorMessage":"Invalid user_agent_patterns: {e}","messagePattern":"Invalid user_agent_patterns: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lore-server/src/server.rs","lineNumber":1677,"sourceCode":"            .inner\n            .map(|provider| provider.detectors(runtime_handle.clone()))\n            .unwrap_or_default();\n        detectors.extend(self.registry.resource_detectors(runtime_handle));\n        detectors\n    }\n}\n\nasync fn async_main(settings: (Settings, StringHash), config: ServerConfig) -> Result<()> {\n    // Initialize metrics and tracing telemetry, returns a guard that will cleanup when it falls out\n    // of scope\n    let (settings, settings_hash) = settings;\n    let runtime = runtime();\n    let telemetry = settings.telemetry.clone().unwrap_or_default();\n    let metrics_config = telemetry.metrics.clone().unwrap_or_default();\n    let ua = &settings.server.user_agent;\n    let user_agent_filter = Arc::new(\n        UserAgentFilter::new(&ua.user_agent_patterns)\n            .map_err(|e| anyhow::anyhow!(\"Invalid user_agent_patterns: {e}\"))?\n            .with_unknown_sample_rate(ua.unknown_user_agent_sample_rate),\n    );\n\n    // Initialize the plugin registry before telemetry: start with the\n    // pre-populated registry from config, then register any build.rs-discovered\n    // plugins. This must happen first so that every compiled-in plugin can\n    // contribute OpenTelemetry resource detectors describing the deployment\n    // environment it implies (e.g. AWS region, Nomad allocation).\n    let mut plugin_registry = config.plugin_registry;\n    plugins::register_all_plugins(&mut plugin_registry);\n\n    let _guard = {\n        let resource_detector_provider = PluginResourceDetectorProvider {\n            inner: config.resource_detector_provider.as_deref(),\n            registry: &plugin_registry,\n        };\n        TelemetryInitializer::from_config(\n            &telemetry,","sourceCodeStart":1659,"sourceCodeEnd":1695,"githubUrl":"https://github.com/EpicGames/lore/blob/074eb0b0d1194c997d7cf28b55519e3e197b3e23/lore-server/src/server.rs#L1659-L1695","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\n[server.user_agent]\nuser_agent_patterns = [\"^Mozilla.*[\", \"curl\"]\n\n# after\n[server.user_agent]\nuser_agent_patterns = [\"^Mozilla.*\", \"curl\"]","handlingStrategy":"validation","validationCode":"for pat in &settings.server.user_agent.user_agent_patterns {\n    if let Err(e) = regex::Regex::new(pat) {\n        return Err(format!(\"invalid user_agent_pattern '{pat}': {e}\"));\n    }\n}","typeGuard":"fn valid_patterns(pats: &[String]) -> bool {\n    pats.iter().all(|p| regex::Regex::new(p).is_ok())\n}","tryCatchPattern":"let user_agent_filter = match UserAgentFilter::new(&ua.user_agent_patterns) {\n    Ok(f) => Arc::new(f.with_unknown_sample_rate(ua.unknown_user_agent_sample_rate)),\n    Err(e) => { eprintln!(\"Invalid user_agent_patterns: {e}\"); std::process::exit(2); }\n};","preventionTips":["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"],"tags":["configuration","regex","startup"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"074eb0b0d1194c997d7cf28b55519e3e197b3e23","analyzedAt":"2026-09-13T09:00:57.509Z","contentChangedAt":"2026-09-13T09:00:57.509Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}