{"record":{"id":"3ff84a9c4d554c7b","repo":"quickwit-oss/quickwit","slug":"failed-to-render-config-file-template-environment","errorCode":null,"errorMessage":"failed to render config file template: environment variable `{env_var_key}` is not set and no default value is provided","messagePattern":"failed to render config file template: environment variable `(.+?)` is not set and no default value is provided","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-config/src/templating.rs","lineNumber":74,"sourceCode":"                        .as_str()\n                        .to_string()\n                } else if let Ok(env_var_value) = std::env::var(env_var_key) {\n                    debug!(\n                        env_var_name=%env_var_key,\n                        env_var_value=%env_var_value,\n                        \"environment variable is set, substituting with environment variable value\"\n                    );\n                    env_var_value\n                } else if let Some(default_match) = captures.get(2) {\n                    let default_value = default_match.as_str().to_string();\n                    debug!(\n                        env_var_name=%env_var_key,\n                        default_value=%default_value,\n                        \"environment variable is not set, substituting with default value\"\n                    );\n                    default_value\n                } else {\n                    bail!(\n                        \"failed to render config file template: environment variable \\\n                         `{env_var_key}` is not set and no default value is provided\"\n                    );\n                }\n            };\n            values.insert(env_var_key.to_string(), substitution_value);\n        }\n    }\n    let template = Template::new(template_str).with_regex(&TEMPLATE_ENV_VAR_CAPTURE);\n    let rendered = template\n        .render_string(&values)\n        .context(\"failed to render config file template\")?;\n    Ok(rendered)\n}\n\n#[cfg(test)]\nmod test {\n    use std::env;","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-config/src/templating.rs#L56-L92","documentation":"Quickwit node config files are templates: `{{ get_env(name=\"QW_LISTEN_ADDRESS\", default=\"127.0.0.1\") }}` placeholders are resolved by `render_config` before parsing. If a template references an environment variable that is not set and the call provides no `default=...`, rendering fails with this error and the config never loads.","triggerScenarios":"Calling `render_config` (via `load_node_config_with_env`) on a config file containing `get_env(name=\"X\")` where env var `X` is unset and no default value argument is supplied.","commonSituations":"Deploying Quickwit with a config that assumes env vars set by systemd/Docker/K8s that were never exported; typos in env var names; running the binary locally on a config written for a container environment.","solutions":["Set the referenced environment variable before starting Quickwit (e.g. `export QW_SEARCHER_ADDRESS=0.0.0.0`).","Add a `default=\"...\"` argument to the `get_env` call in the config template.","Check the env var name for typos against what the deployment environment actually provides."],"exampleFix":"// before (quickwit.yaml)\nlisten_address: \"{{ get_env(name=\"QW_LISTEN_ADDRESS\") }}\"\n// after\nlisten_address: \"{{ get_env(name=\"QW_LISTEN_ADDRESS\", default=\"127.0.0.1\") }}\"","handlingStrategy":"try-catch","validationCode":"const required = [...config.matchAll(/get_env\\(name=\"([^\"]+)\"(?![^)]*default)/g)].map(m => m[1]);\nconst missing = required.filter(v => process.env[v] === undefined);\nif (missing.length) throw new Error(`unset config env vars: ${missing.join(\",\")}`);","typeGuard":null,"tryCatchPattern":"match quickwit_config::load_node_config_from_file(&path) {\n    Ok(cfg) => start_with(cfg),\n    Err(e) if e.to_string().contains(\"is not set and no default value\") => {\n        eprintln!(\"missing env var for config template: {e}\");\n        std::process::exit(78); // config error\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always provide a `default=\"...\"` in get_env calls for optional settings.","Declare required env vars in your deployment manifest (systemd EnvironmentFile, K8s env).","Smoke-test config rendering in CI with a minimal env."],"tags":["config","environment-variable","templating","startup"],"backgroundTag":"missing-env-var","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}