quickwit-oss/quickwit · error

{} contains an empty label name: {}

Error message

{} contains an empty label name: {}

What it means

`parse_metrics_labels`, which parses the `QW_METRICS_LABELS` environment variable into Prometheus labels, found a `name=value` pair whose name side is empty after trimming (e.g. `=foo` or ` , =foo`). The labels are appended to all Quickwit metrics, and Prometheus rejects empty label names, so parsing aborts.

Source

Thrown at quickwit/quickwit-metrics/src/lib.rs:437

    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,
                label
            );
        }
        let label = Label::new(name.to_string(), value.to_string());
        parsed_labels.push(label);
    }

    Ok(parsed_labels)

View on GitHub (pinned to a39730c5cd)

Solutions

  1. Ensure every entry in `QW_METRICS_LABELS` has the form `name=value` with a non-empty name
  2. Check for stray commas producing empty segments and quote the value if needed

Example fix

// before
export QW_METRICS_LABELS_ENV_VAR="=prod,team=obs"
// after
export QW_METRICS_LABELS_ENV_VAR="cluster=prod,team=obs"
Defensive patterns

Strategy: validation

Validate before calling

fn labels_valid(s: &str) -> bool {
    s.split(',').all(|l| {
        let mut it = l.splitn(2, '=');
        it.next().map(|n| !n.trim().is_empty()).unwrap_or(false)
            && it.next().map(|v| !v.trim().is_empty()).unwrap_or(false)
    })
}

Try / catch

if let Err(e) = init_metrics_labels_env_var() {
    if e.to_string().contains("empty label name") {
        eprintln!("bad QW_METRICS_LABELS_ENV_VAR: {e}");
    }
}

Prevention

When it happens

Trigger: Setting QW_METRICS_LABELS_ENV_VAR with a comma-separated entry lacking a name, such as "=value" or " ,cluster=prod", or a leading/trailing comma producing an empty fragment.

Common situations: Typos in the env var like "=prod"; copy-paste with trailing comma "a=b,c=d,"; misbuilt label strings missing the key.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of quickwit-oss/quickwit@a39730c5cd (2026-09-08). Data as JSON: /api/errors/fdcf076e1956a198. Report an issue: GitHub.