{"record":{"id":"0960047f7f37275a","repo":"BoundaryML/baml","slug":"configuration-error-0","errorCode":null,"errorMessage":"Configuration error: {0}","messagePattern":"Configuration error: (.+?)","errorType":"exception","errorClass":"LogError","httpStatus":null,"severity":"error","filePath":"engine/baml-lib/baml-log/src/logger.rs","lineNumber":423,"sourceCode":"}\n\n/// Error type for logging operations\n#[derive(Debug, Error)]\npub enum LogError {\n    /// Error writing to output\n    #[error(\"IO error: {0}\")]\n    Io(#[from] io::Error),\n\n    /// Error serializing to JSON\n    #[error(\"JSON serialization error: {0}\")]\n    Json(#[from] serde_json::Error),\n\n    /// Error acquiring lock\n    #[error(\"Failed to acquire lock\")]\n    LockError,\n\n    /// Configuration error\n    #[error(\"Configuration error: {0}\")]\n    Config(String),\n}\n\n// /// JSON-serializable log entry\n// #[derive(Serialize)]\n// struct LogEntry<'a> {\n//     /// Timestamp in ISO 8601 format\n//     timestamp: String,\n//     /// Log level as a string\n//     level: &'a str,\n//     /// Log message\n//     message: String,\n//     /// Optional module path\n//     #[serde(skip_serializing_if = \"Option::is_none\")]\n//     module_path: Option<&'a str>,\n//     /// Optional file name\n//     #[serde(skip_serializing_if = \"Option::is_none\")]\n//     file: Option<&'a str>,","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/baml-log/src/logger.rs#L405-L441","documentation":"This is the `LogError::Config(String)` variant of BAML's logging `LogError` enum in baml-log. It signals that an operation on the logger failed because of a problem with the logger's configuration payload (an invalid or inconsistent LogConfig value passed to logging setup or emission code). The String payload carries the specific configuration problem reported by the caller.","triggerScenarios":"Constructing or mutating the global LogConfig (held behind a lazy_static RwLock) with invalid values — e.g. an unparsable log level, an invalid log-file path configuration, or calling a logger API with a config object whose fields are inconsistent (format set but file path missing). The error surfaces wherever code returns LogError::Config(msg) from config-handling paths in logger.rs.","commonSituations":"Setting BAML log-related environment variables to invalid values that LogConfig::from_env or a runtime setter consumes; programmatically reconfiguring the logger at runtime (the 'runtime modification support' on CONFIG) with a bad value; wiring a custom log sink/file path that config validation rejects.","solutions":["Read the embedded String message — it names the exact config field/value that was rejected; fix that value.","Validate the log configuration (level string, file path) before passing it to the logger API.","Check environment variables feeding LogConfig::from_env for typos or unsupported values and correct them.","If reconfiguring at runtime, ensure the new LogConfig is fully constructed via its builder/constructor rather than patched field-by-field."],"exampleFix":"// before\nlet cfg = LogConfig { level: \"verrbose\".into(), ..Default::default() };\nlogger.set_config(cfg)?; // Configuration error: invalid log level 'verrbose'\n// after\nlet cfg = LogConfig { level: \"verbose\".into(), ..Default::default() };\ndebug_assert!(cfg.level.is_valid());\nlogger.set_config(cfg)?;","handlingStrategy":"validation","validationCode":"// Rust: validate log config before handing it to the logger\nfn validate_log_config(level: &str, file: Option<&Path>) -> Result<(), String> {\n    match level.to_ascii_lowercase().as_str() {\n        \"trace\" | \"debug\" | \"info\" | \"warn\" | \"error\" => {}\n        other => return Err(format!(\"invalid log level: {other}\")),\n    }\n    if let Some(p) = file {\n        if !p.as_os_str().is_empty() {\n            return Err(\"log file path configured but empty\".into());\n        }\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate log level strings and file paths before constructing LogConfig","Prefer LogConfig's own constructors/builders over hand-built structs","Check BAML log-related env vars in deployment configs during CI","When mutating logger config at runtime, construct a complete new LogConfig rather than patching fields"],"tags":["rust","logging","configuration","baml"],"backgroundTag":"invalid-config-value","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}