{"record":{"id":"7199b537632a3c94","repo":"BoundaryML/baml","slug":"failed-to-parse-config-from-environment-variables-boundary-e","errorCode":null,"errorMessage":"Failed to parse config from environment variables: BOUNDARY_{}: {e}","messagePattern":"Failed to parse config from environment variables: BOUNDARY_(.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/tracing/api_wrapper/env_setup.rs","lineNumber":66,"sourceCode":"        // Mirror `envy::prefixed(\"BOUNDARY_\")`: keep only BOUNDARY_-prefixed keys,\n        // strip the prefix, and lowercase the remainder to match field names.\n        let map: std::collections::HashMap<String, String> = env_vars\n            .filter_map(|(k, v)| {\n                k.as_ref()\n                    .strip_prefix(\"BOUNDARY_\")\n                    .map(|rest| (rest.to_ascii_lowercase(), v.as_ref().to_string()))\n            })\n            .collect();\n\n        let get = |k: &str| map.get(k).cloned();\n\n        fn parse_field<T>(key: &str, raw: &str) -> Result<T>\n        where\n            T: std::str::FromStr,\n            T::Err: std::fmt::Display,\n        {\n            raw.parse::<T>().map_err(|e| {\n                anyhow::anyhow!(\n                    \"Failed to parse config from environment variables: BOUNDARY_{}: {e}\",\n                    key.to_ascii_uppercase()\n                )\n            })\n        }\n\n        let config = Config {\n            base_url: get(\"base_url\").unwrap_or_else(default_base_url),\n            secret: get(\"secret\"),\n            project_id: get(\"project_id\"),\n            sessions_id: get(\"sessions_id\").unwrap_or_else(default_sessions_id),\n            stage: get(\"stage\").unwrap_or_else(default_stage),\n            host_name: get(\"host_name\").unwrap_or_else(default_host_name),\n            log_redaction_enabled: match get(\"log_redaction_enabled\") {\n                Some(s) => parse_field(\"log_redaction_enabled\", &s)?,\n                None => false,\n            },\n            log_redaction_placeholder: get(\"log_redaction_placeholder\")","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/tracing/api_wrapper/env_setup.rs#L48-L84","documentation":"The BAML tracing API wrapper reads BOUNDARY_* environment variables for its configuration and parses each with FromStr. When a variable's raw string cannot be parsed into the expected type, `parse_field` wraps the underlying parse error in this anyhow error, naming the offending variable.","triggerScenarios":"Setting a BOUNDARY_* env var (e.g. BOUNDARY_URL-related numeric/boolean fields) to a value that fails FromStr parsing, e.g. `BOUNDARY_VERBOSE=notabool` or a port set to `abc`.","commonSituations":"Typos or stray quotes/whitespace in environment values (CI secrets with trailing newline); setting a boolean to 'True' where the parser expects lowercase 'true' or '1'; mixing up which variable takes an integer vs a string.","solutions":["Inspect the BOUNDARY_<KEY> named in the message and set it to a value parseable as the expected type (e.g. bool: true/false/1/0).","Remove surrounding quotes, spaces, and trailing newlines from the env var value (`export BOUNDARY_VERBOSE=true`, not `\"true\" `).","Unset the variable entirely if you want the default, instead of supplying an unparseable placeholder."],"exampleFix":"// before\nexport BOUNDARY_VERBOSE=\"True \"   // fails FromStr<bool>\n// after\nexport BOUNDARY_VERBOSE=true","handlingStrategy":"validation","validationCode":"// Shell: sanity-check BOUNDARY_* vars before launching\nenv | grep '^BOUNDARY_' | while IFS='=' read -r k v; do\n  case \"$k\" in\n    *VERBOSE|*ENABLED) [[ \"$v\" =~ ^(true|false|1|0)$ ]] || { echo \"bad bool $k=$v\"; exit 1; } ;;\n    *PORT|*TIMEOUT|*LIMIT) [[ \"$v\" =~ ^[0-9]+$ ]] || { echo \"bad number $k=$v\"; exit 1; } ;;\n  esac\ndone","typeGuard":null,"tryCatchPattern":"// Rust: wrap config construction\nlet cfg = Config::from_env().map_err(|e| {\n    eprintln!(\"{e:#}; check the named BOUNDARY_ variable's format\");\n    e\n})?;","preventionTips":["Avoid quotes and whitespace in BOUNDARY_* env values.","Use lowercase true/false (or 1/0) for boolean variables.","Scrub CI secrets for trailing newlines before exporting them.","Unset variables you do not intend to override."],"tags":["environment","config","parsing","tracing"],"backgroundTag":"invalid-env-var-value","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}