{"record":{"id":"91add1a1b5896606","repo":"quickwit-oss/quickwit","slug":"contains-invalid-label-format","errorCode":null,"errorMessage":"{} contains invalid label format: {}","messagePattern":"(.+?) contains invalid label format: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-metrics/src/lib.rs","lineNumber":429,"sourceCode":"    LABELS_ENV_VAR.get_or_init(|| parsed_labels.into_boxed_slice());\n\n    Ok(())\n}\n\n// The format of the environment variable is:\n// QW_METRICS_LABELS=\"environment=test,region=us-east-1,foo=bar\"\nfn parse_metrics_labels(labels: &str) -> anyhow::Result<Vec<Label>> {\n    let mut parsed_labels: Vec<Label> = Vec::new();\n    if labels.trim().is_empty() {\n        return Ok(parsed_labels);\n    }\n\n    const LABELS_SEPARATOR: char = ',';\n    const KEY_VALUE_SEPARATOR: char = '=';\n\n    for label in labels.split(LABELS_SEPARATOR) {\n        let (name, value) = label.split_once(KEY_VALUE_SEPARATOR).ok_or_else(|| {\n            anyhow::anyhow!(\n                \"{} contains invalid label format: {}\",\n                QW_METRICS_LABELS_ENV_VAR,\n                label\n            )\n        })?;\n        let name = name.trim();\n        if name.is_empty() {\n            anyhow::bail!(\n                \"{} contains an empty label name: {}\",\n                QW_METRICS_LABELS_ENV_VAR,\n                label\n            );\n        }\n        let value = value.trim();\n        if value.is_empty() {\n            anyhow::bail!(\n                \"{} contains an empty label value: {}\",\n                QW_METRICS_LABELS_ENV_VAR,","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-metrics/src/lib.rs#L411-L447","documentation":"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.","triggerScenarios":"Setting QW_METRICS_LABELS to a value like 'env=prod,region' (a token without '=') and calling init_metrics_labels_env_var at startup.","commonSituations":"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.","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."],"exampleFix":"// before\nexport QW_METRICS_LABELS=\"env=prod region\"\n// after\nexport QW_METRICS_LABELS=\"env=prod,region=us-east-1\"","handlingStrategy":"validation","validationCode":"let labels = std::env::var(\"QW_METRICS_LABELS\").unwrap_or_default();\nfor token in labels.split(',').filter(|t| !t.is_empty()) {\n    assert!(token.contains('='), \"invalid label token: {}\", token);\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = init_metrics_labels_env_var() {\n    eprintln!(\"invalid QW_METRICS_LABELS: {e}; expected name=value pairs comma-separated\");\n}","preventionTips":["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."],"tags":["metrics","env-var","parsing","configuration"],"backgroundTag":"invalid-argument-format","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}