{"record":{"id":"95ac5aee36138f0f","repo":"nautechsystems/nautilus_trader","slug":"invalid-log-level-string-s","errorCode":null,"errorMessage":"Invalid log level string: '{s}'","messagePattern":"Invalid log level string: '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/common/src/logging/mod.rs","lineNumber":232,"sourceCode":"        LogLevel::Debug => LevelFilter::Debug,\n        LogLevel::Info => LevelFilter::Info,\n        LogLevel::Warning => LevelFilter::Warn,\n        LogLevel::Error => LevelFilter::Error,\n    }\n}\n\n/// Parses a string into a [`LevelFilter`].\n///\n/// # Errors\n///\n/// Returns an error if the provided string is not a valid `LevelFilter`.\npub fn parse_level_filter_str(s: &str) -> anyhow::Result<LevelFilter> {\n    let mut log_level_str = s.to_uppercase();\n    if log_level_str == \"WARNING\" {\n        log_level_str = \"WARN\".to_string();\n    }\n    LevelFilter::from_str(&log_level_str)\n        .map_err(|_| anyhow::anyhow!(\"Invalid log level string: '{s}'\"))\n}\n\n/// Parses component-specific log levels from a JSON value map.\n///\n/// # Errors\n///\n/// Returns an error if a JSON value in the map is not a string or is not a valid log level.\npub fn parse_component_levels(\n    original_map: Option<HashMap<String, serde_json::Value>>,\n) -> anyhow::Result<AHashMap<Ustr, LevelFilter>> {\n    let mut new_map = AHashMap::new();\n\n    for (key, value) in original_map.unwrap_or_default() {\n        let ustr_key = Ustr::from(&key);\n        let s = value.as_str().ok_or_else(|| {\n            anyhow::anyhow!(\"Component log level for '{key}' must be a string, was: {value}\")\n        })?;\n        let lvl = parse_level_filter_str(s)?;","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/logging/mod.rs#L214-L250","documentation":"Raised by parse_level_filter_str when a log level string cannot be parsed into a tracing LevelFilter. The input is uppercased (with 'WARNING' mapped to 'WARN') and passed to LevelFilter::from_str; any string not matching a valid level name produces this error wrapping the original input.","triggerScenarios":"Calling parse_level_filter_str with a string other than TRACE/DEBUG/INFO/WARN/WARNING/ERROR/OFF (case-insensitive), e.g. 'verbose', 'log', 'fatal'.","commonSituations":"Typos or invalid values in RUST_LOG-style environment configuration, log-level entries in a JSON config map for components, or user-supplied CLI log level values.","solutions":["Use one of the valid level strings: TRACE, DEBUG, INFO, WARN (or WARNING), ERROR, OFF.","Validate/normalize user or config supplied log levels before passing them to the parser.","Check for typos or locale/format variations (e.g. 'Info ' with trailing whitespace) in the input."],"exampleFix":"// before\nparse_level_filter_str(\"verbose\")?;\n// after\nparse_level_filter_str(\"DEBUG\")?;","handlingStrategy":"validation","validationCode":"const VALID_LEVELS: [&str; 6] = [\"TRACE\", \"DEBUG\", \"INFO\", \"WARN\", \"ERROR\", \"OFF\"];\nfn is_valid_level(s: &str) -> bool {\n    let up = s.trim().to_uppercase();\n    up == \"WARNING\" || VALID_LEVELS.contains(&up.as_str())\n}\nassert!(is_valid_level(user_level), \"invalid log level: {user_level}\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate log level strings against TRACE/DEBUG/INFO/WARN/WARNING/ERROR/OFF before parsing.","Trim and uppercase user/config supplied levels to avoid case and whitespace issues.","Centralize level parsing through parse_level_filter_str instead of ad-hoc string matching.","Document accepted level values wherever log levels are configured."],"tags":["rust","logging","parsing","configuration"],"backgroundTag":"invalid-enum-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}