BoundaryML/baml · error
Failed to parse config from environment variables: BOUNDARY_
Error message
Failed to parse config from environment variables: BOUNDARY_{}: {e} What it means
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.
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.
Example fix
// before export BOUNDARY_VERBOSE="True " // fails FromStr<bool> // after export BOUNDARY_VERBOSE=true
Defensive patterns
Strategy: validation
Validate before calling
// Shell: sanity-check BOUNDARY_* vars before launching
env | grep '^BOUNDARY_' | while IFS='=' read -r k v; do
case "$k" in
*VERBOSE|*ENABLED) [[ "$v" =~ ^(true|false|1|0)$ ]] || { echo "bad bool $k=$v"; exit 1; } ;;
*PORT|*TIMEOUT|*LIMIT) [[ "$v" =~ ^[0-9]+$ ]] || { echo "bad number $k=$v"; exit 1; } ;;
esac
done Try / catch
// Rust: wrap config construction
let cfg = Config::from_env().map_err(|e| {
eprintln!("{e:#}; check the named BOUNDARY_ variable's format");
e
})?; Prevention
- 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.
When it happens
Trigger: 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`.
Common situations: 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.
Understand the failure class
Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- AWS region is required to build modular request. Set it in…
- Environment variable
- Failed to resolve expression
- Already used span
- artifact ` ` (kind = "pack") sets ` `, which is ignored for…
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/7199b537632a3c94.
Report an issue: GitHub.
Appendix: source
Thrown at engine/baml-runtime/src/tracing/api_wrapper/env_setup.rs:66
// Mirror `envy::prefixed("BOUNDARY_")`: keep only BOUNDARY_-prefixed keys,
// strip the prefix, and lowercase the remainder to match field names.
let map: std::collections::HashMap<String, String> = env_vars
.filter_map(|(k, v)| {
k.as_ref()
.strip_prefix("BOUNDARY_")
.map(|rest| (rest.to_ascii_lowercase(), v.as_ref().to_string()))
})
.collect();
let get = |k: &str| map.get(k).cloned();
fn parse_field<T>(key: &str, raw: &str) -> Result<T>
where
T: std::str::FromStr,
T::Err: std::fmt::Display,
{
raw.parse::<T>().map_err(|e| {
anyhow::anyhow!(
"Failed to parse config from environment variables: BOUNDARY_{}: {e}",
key.to_ascii_uppercase()
)
})
}
let config = Config {
base_url: get("base_url").unwrap_or_else(default_base_url),
secret: get("secret"),
project_id: get("project_id"),
sessions_id: get("sessions_id").unwrap_or_else(default_sessions_id),
stage: get("stage").unwrap_or_else(default_stage),
host_name: get("host_name").unwrap_or_else(default_host_name),
log_redaction_enabled: match get("log_redaction_enabled") {
Some(s) => parse_field("log_redaction_enabled", &s)?,
None => false,
},
log_redaction_placeholder: get("log_redaction_placeholder")View on GitHub (pinned to bd85ce9dee)