Kuberwastaken/claurst · error
Invalid env-var format
Error message
Invalid env-var format '{}': expected KEY=VALUE What it means
Thrown by `parse_env_vars` in src-rust/crates/core/src/feature_gates.rs when an entry in the input list contains no `=` character, so it cannot be split into KEY and VALUE. The parser requires every entry to be in KEY=VALUE form and fails fast on the first malformed entry.
Solutions
- Rewrite the entry as KEY=VALUE (e.g. "DEBUG=1" instead of "DEBUG").
- If the intent is only to assert an env var exists, use "KEY=1" or any placeholder value.
- Trim the input list to remove empty strings caused by trailing separators.
- Validate entries with `entry.contains('=')` before passing them to the parser.
Example fix
// before parse_env_vars(&["DEBUG", "RUST_LOG=info"])?; // after parse_env_vars(&["DEBUG=1", "RUST_LOG=info"])?;
Defensive patterns
Strategy: validation
Validate before calling
fn valid_env_entries(entries: &[String]) -> bool {
entries.iter().all(|e| !e.is_empty() && e.contains('='))
} Type guard
fn as_key_value(entry: &str) -> Option<(&str, &str)> {
let pos = entry.find('=')?;
Some((&entry[..pos], &entry[pos + 1..]))
} Try / catch
match parse_env_vars(&entries) {
Ok(map) => use(map),
Err(e) if e.to_string().contains("Invalid env-var format") => {
// surface which entry was malformed to the user
report_bad_entry(&entries, &e);
}
Err(e) => return Err(e),
} Prevention
- Always write env entries as KEY=VALUE, even for existence checks (KEY=1).
- Trim lists and drop empty strings before parsing.
- Validate entries with entry.contains('=') at config-load time.
- Never mix bare variable names with KEY=VALUE pairs in one list.
When it happens
Trigger: Passing a bare variable name without `=` (e.g. "DEBUG") or an empty/whitespace-only string to parse_env_vars; callers like parse_env_vars_basic forward user-supplied gate config entries verbatim.
Common situations: Config listing env var names to check for existence but written without `=VALUE`; copy-pasted settings where `=` was lost; YAML/TOML lists mixing names and KEY=VALUE pairs; trailing empty string from a split on ',' with a trailing comma.
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.
Related errors
- Plugin name cannot be empty
- Plugin name ' ' cannot contain spaces. Use kebab-case.
- Remote Control requires a session token. Set…
- source settings.json must be a JSON object
- mcpServers must be an object
AI-assisted analysis of Kuberwastaken/claurst@b0637c97ec (2026-09-10).
Data as JSON: /api/errors/7f1c2fb7118e05ed.
Report an issue: GitHub.
Appendix: source
Thrown at src-rust/crates/core/src/feature_gates.rs:131
}
}
// ---------------------------------------------------------------------------
// Env-var parsing for --env KEY=VALUE arguments
// ---------------------------------------------------------------------------
/// Parse a slice of `"KEY=VALUE"` strings into a `HashMap`.
///
/// Returns an error if any entry lacks a `=` separator.
pub fn parse_env_vars(args: &[String]) -> anyhow::Result<HashMap<String, String>> {
let mut map = HashMap::new();
for entry in args {
if let Some(pos) = entry.find('=') {
let key = entry[..pos].to_string();
let value = entry[pos + 1..].to_string();
map.insert(key, value);
} else {
return Err(anyhow::anyhow!(
"Invalid env-var format '{}': expected KEY=VALUE",
entry
));
}
}
Ok(map)
}
// ---------------------------------------------------------------------------
// AWS region
// ---------------------------------------------------------------------------
/// Resolve the AWS region, checking `AWS_REGION` then `AWS_DEFAULT_REGION`,
/// falling back to `"us-east-1"`.
pub fn get_aws_region() -> String {
std::env::var("AWS_REGION")
.or_else(|_| std::env::var("AWS_DEFAULT_REGION"))
.unwrap_or_else(|_| "us-east-1".to_string())
View on GitHub (pinned to b0637c97ec)