{"record":{"id":"679d45a63e48efd8","repo":"nautechsystems/nautilus_trader","slug":"invalid-spec-pair-kv","errorCode":null,"errorMessage":"Invalid spec pair: {kv}","messagePattern":"Invalid spec pair: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/common/src/logging/config.rs","lineNumber":224,"sourceCode":"        let mut config = Self::default();\n\n        for kv in spec.split(';') {\n            let kv = kv.trim();\n            if kv.is_empty() {\n                continue;\n            }\n\n            let Some((k, v)) = kv.split_once('=') else {\n                // Handle bare flags (without =)\n                match kv.to_lowercase().as_str() {\n                    \"log_components_only\" => config.log_components_only = true,\n                    \"is_colored\" => config.is_colored = true,\n                    \"print_config\" => config.print_config = true,\n                    \"use_tracing\" => config.use_tracing = true,\n                    \"bypass_logging\" => config.bypass_logging = true,\n                    \"fileout_sync_on_flush\" => config.fileout_sync_on_flush = true,\n                    \"buffered_stdout\" => config.buffered_stdout = true,\n                    _ => anyhow::bail!(\"Invalid spec pair: {kv}\"),\n                }\n                continue;\n            };\n\n            let k = k.trim();\n            let v = v.trim();\n            let k_lower = k.to_lowercase();\n\n            match k_lower.as_str() {\n                \"is_colored\" => {\n                    config.is_colored = parse_bool_value(v);\n                }\n                \"log_components_only\" => {\n                    config.log_components_only = parse_bool_value(v);\n                }\n                \"print_config\" => {\n                    config.print_config = parse_bool_value(v);\n                }","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/logging/config.rs#L206-L242","documentation":"LoggingSpec::from_spec parses a comma-separated key=value spec string into a LoggingConfig. When a key is not one of the recognized flag keys (is_colored, print_config, use_tracing, bypass_logging, fileout_sync_on_flush, buffered_stdout, etc.) the parser aborts with this error. It means the spec string contains an unrecognized key or is malformed.","triggerScenarios":"Calling from_spec (or the higher-level env/config parsing that delegates to it) with a spec pair whose key is not in the accepted set, e.g. `color=true` instead of `is_colored=true`, or a bare token like `verbose` without `=` that falls through to the flag/pair branches and fails.","commonSituations":"Typos in environment-variable-driven logging config (e.g. NAUTILUS_LOG spec strings), copying spec options from documentation of a different version where a key was renamed or removed, or accidentally passing free-form text as a spec.","solutions":["Check the spec string and correct the key spelling to one of the supported keys (is_colored, print_config, use_tracing, bypass_logging, fileout_sync_on_flush, buffered_stdout).","Verify each pair is formatted `key=value` with no stray separators or whitespace-only tokens.","Check the version of the crate you are using: some spec keys exist only in certain releases; consult the config module docs for that version.","Remove options that are not supported and set them programmatically on LoggingConfig instead."],"exampleFix":"// before\nlet config = LoggingSpec::from_spec(\"color=true,print_config\")?;\n// after\nlet config = LoggingSpec::from_spec(\"is_colored=true,print_config=true\")?;","handlingStrategy":"validation","validationCode":"const VALID_KEYS: [&str; 6] = [\"is_colored\", \"print_config\", \"use_tracing\", \"bypass_logging\", \"fileout_sync_on_flush\", \"buffered_stdout\"];\nfn spec_keys_valid(spec: &str) -> bool {\n    spec.split(',').all(|kv| {\n        let key = kv.split('=').next().unwrap_or(\"\").trim();\n        VALID_KEYS.contains(&key)\n    });\n}","typeGuard":null,"tryCatchPattern":"match LoggingSpec::from_spec(spec) {\n    Ok(cfg) => cfg,\n    Err(e) if e.to_string().contains(\"Invalid spec pair\") => {\n        eprintln!(\"bad logging spec '{spec}': {e}\");\n        LoggingSpec::default()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep spec strings centralized in one constant rather than scattered literals.","Add a unit test that parses every documented spec key.","Copy spec examples only from the docs of the exact crate version in use."],"tags":["logging","config-parsing","rust"],"backgroundTag":"invalid-config-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"}