affaan-m/ECC · error · anyhow::Error
{label} must use non-empty key=value form: {value}
Error message
{label} must use non-empty key=value form: {value} What it means
Thrown by parse_key_value_pairs when an entry does contain '=' but either the key or the value is empty after trimming whitespace. The parser requires both sides to be non-empty, so '=value', 'key=', or ' = ' are all rejected.
Source
Thrown at ecc2/src/main.rs:8597
priority: comms::TaskPriority::Normal,
},
)
}
fn parse_template_vars(values: &[String]) -> Result<BTreeMap<String, String>> {
parse_key_value_pairs(values, "template vars")
}
fn parse_key_value_pairs(values: &[String], label: &str) -> Result<BTreeMap<String, String>> {
let mut vars = BTreeMap::new();
for value in values {
let (key, raw_value) = value
.split_once('=')
.ok_or_else(|| anyhow::anyhow!("{label} must use key=value form: {value}"))?;
let key = key.trim();
let raw_value = raw_value.trim();
if key.is_empty() || raw_value.is_empty() {
anyhow::bail!("{label} must use non-empty key=value form: {value}");
}
vars.insert(key.to_string(), raw_value.to_string());
}
Ok(vars)
}
#[cfg(test)]
mod tests {
use super::*;
use crate::config::Config;
use crate::session::store::StateStore;
use crate::session::{Session, SessionMetrics, SessionState};
use chrono::{Duration, Utc};
use std::fs;
use std::path::{Path, PathBuf};
struct TestDir {
path: PathBuf,View on GitHub (pinned to 01e15490f0)
Solutions
- Provide a non-empty key and value: '--var component=billing'.
- If the value comes from an env var, ensure it is set (e.g. 'export ENV=dev') or supply a default before running the command.
- Strip accidental whitespace around the '=' so neither side is blank.
- Inspect the failing value from the error message and correct that specific entry.
Example fix
# before (ENV unset -> empty value) ecc2 run --var env=$ENV # after export ENV=dev ecc2 run --var env=$ENV
Defensive patterns
Strategy: validation
Validate before calling
fn is_nonempty_key_value(entry: &str) -> bool {
match entry.split_once('=') {
Some((k, v)) => !k.trim().is_empty() && !v.trim().is_empty(),
None => false,
}
} Prevention
- Ensure env-derived values are set before expanding them into args.
- Trim and check both halves of each key=value entry.
- Add a CLI pre-flight check that rejects empty keys or values.
When it happens
Trigger: Passing '--var =billing' (empty key), '--var component=' (empty value), or '--var = ' (both empty). Also when a template substitution leaves the value blank, e.g. '--var env=$ENV' where $ENV is unset.
Common situations: Empty environment variable expanded into the value; user clears a value by mistake; trailing '=' after editing; whitespace-only key or value.
Related errors
- {label} must use key=value form: {value}
- Legacy workspace source must be a directory: {}
- Unknown argument: ${arg}
- Unknown argument: ${arg}
- --timeout-ms must be a positive number
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/c84ab61b280036c9.
Report an issue: GitHub.