quickwit-oss/quickwit · error
{} contains invalid label format: {}
Error message
{} contains invalid label format: {} What it means
init_metrics_labels_env_var parses the QW_METRICS_LABELS environment variable, which must be a comma-separated list of name=value pairs. parse_metrics_labels fails on any comma-separated token that lacks an '=' separator, naming the offending token in the message.
Source
Thrown at quickwit/quickwit-metrics/src/lib.rs:429
LABELS_ENV_VAR.get_or_init(|| parsed_labels.into_boxed_slice());
Ok(())
}
// The format of the environment variable is:
// QW_METRICS_LABELS="environment=test,region=us-east-1,foo=bar"
fn parse_metrics_labels(labels: &str) -> anyhow::Result<Vec<Label>> {
let mut parsed_labels: Vec<Label> = Vec::new();
if labels.trim().is_empty() {
return Ok(parsed_labels);
}
const LABELS_SEPARATOR: char = ',';
const KEY_VALUE_SEPARATOR: char = '=';
for label in labels.split(LABELS_SEPARATOR) {
let (name, value) = label.split_once(KEY_VALUE_SEPARATOR).ok_or_else(|| {
anyhow::anyhow!(
"{} contains invalid label format: {}",
QW_METRICS_LABELS_ENV_VAR,
label
)
})?;
let name = name.trim();
if name.is_empty() {
anyhow::bail!(
"{} contains an empty label name: {}",
QW_METRICS_LABELS_ENV_VAR,
label
);
}
let value = value.trim();
if value.is_empty() {
anyhow::bail!(
"{} contains an empty label value: {}",
QW_METRICS_LABELS_ENV_VAR,View on GitHub (pinned to a39730c5cd)
Solutions
- Fix QW_METRICS_LABELS so every token is name=value, e.g. QW_METRICS_LABELS='env=prod,region=us-east-1'.
- Remove empty or malformed tokens (a trailing comma creates an empty token — though empty input itself is accepted).
- Quote carefully in shell: use single quotes to avoid shell mangling '=' or spaces.
Example fix
// before export QW_METRICS_LABELS="env=prod region" // after export QW_METRICS_LABELS="env=prod,region=us-east-1"
Defensive patterns
Strategy: validation
Validate before calling
let labels = std::env::var("QW_METRICS_LABELS").unwrap_or_default();
for token in labels.split(',').filter(|t| !t.is_empty()) {
assert!(token.contains('='), "invalid label token: {}", token);
} Try / catch
if let Err(e) = init_metrics_labels_env_var() {
eprintln!("invalid QW_METRICS_LABELS: {e}; expected name=value pairs comma-separated");
} Prevention
- Use single-quoted shell values: QW_METRICS_LABELS='env=prod,region=us-east-1'.
- Validate the env var in your deployment pipeline before rollout.
- Remember format is strictly name=value tokens joined by commas.
When it happens
Trigger: Setting QW_METRICS_LABELS to a value like 'env=prod,region' (a token without '=') and calling init_metrics_labels_env_var at startup.
Common situations: Typos in the env var value (space instead of '=', missing value); copy-pasting Prometheus label syntax with different separators; forgetting that pairs are comma-separated with no quoting.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- unknown URI protocol `{protocol}`
- {QW_METRICS_LABELS_ENV_VAR} must contain valid Unicode
- {} contains an empty label name: {}
- {} contains an empty label value: {}
- lambda memory must be at least 1GB
AI-assisted analysis of quickwit-oss/quickwit@a39730c5cd (2026-09-08).
Data as JSON: /api/errors/91add1a1b5896606.
Report an issue: GitHub.