{"record":{"id":"2db230579a9f12c8","repo":"quickwit-oss/quickwit","slug":"failed-to-convert-value-env-var-value-read-fro","errorCode":null,"errorMessage":"failed to convert value `{env_var_value}` read from environment variable `{env_var_key}` to type `{}`: {error:?}","messagePattern":"failed to convert value `(.+?)` read from environment variable `(.+?)` to type `(.+?)`: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-config/src/config_value.rs","lineNumber":85,"sourceCode":"        env_vars: &HashMap<String, String>,\n    ) -> anyhow::Result<Option<T>> {\n        // QW env vars take precedence over the config file values.\n        if E > QW_NONE\n            && let Some(env_var_key) = QW_ENV_VARS.get(&E)\n            && let Some(env_var_value) = env_vars.get(*env_var_key).filter(|val| {\n                if val.is_empty() {\n                    warn!(\n                        \"environment variable `{}` is set but value is empty\",\n                        *env_var_key\n                    );\n                    false\n                } else {\n                    true\n                }\n            })\n        {\n            let value = env_var_value.parse::<T>().map_err(|error| {\n                anyhow::anyhow!(\n                    \"failed to convert value `{env_var_value}` read from environment variable \\\n                     `{env_var_key}` to type `{}`: {error:?}\",\n                    any::type_name::<T>(),\n                )\n            })?;\n            return Ok(Some(value));\n        }\n        Ok(self.provided.or(self.default))\n    }\n\n    pub(crate) fn resolve(self, env_vars: &HashMap<String, String>) -> anyhow::Result<T> {\n        self.resolve_optional(env_vars)?.context(\n            \"failed to resolve field value: no value was provided via environment variable or \\\n             config file, and the field has no default\",\n        )\n    }\n}\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-config/src/config_value.rs#L67-L103","documentation":"quickwit-config resolves configuration values from environment variables. `resolve_optional` parses the raw string of an env var into the target type T; if `str::parse` fails, this error is thrown, reporting the value, variable name, target type, and the parse error.","triggerScenarios":"Setting an environment variable that a config value resolves from (via qw env-var interpolation of QW_ prefixed variables) with a value that cannot parse into the declared Rust type, e.g. QW_LISTENER_HTTP_PORT=\"http\" for a u16, or QW_GRPC_MAX_MESSAGE_SIZE=\"twenty-megabytes\" for a ByteSize.","commonSituations":"Typos or whitespace in env var values; passing human-friendly strings where numbers/durations/sizes are expected; shell exporting quoted values that include quotes; wrong variable name mapping to the wrong type; changed unit formats across Quickwit versions.","solutions":["Inspect the env var named in the message and print its raw value (`printenv {env_var_key}`), then set it to a value valid for the type shown (u64/u32, ByteSize like `20MB`, duration like `30s`, bool like `true`).","Watch for stray whitespace, BOM, or quotes: `export QW_X=$(tr -d '\"\\'' <<< \"$QW_X\")` or re-export the value cleanly.","If the value was intended as a literal default and not an override, unset the env var (`unset {env_var_key}`) so the config file/default is used.","Check docs for the expected format of that setting — unit suffixes (MB, MiB, s, ms) are required for size/duration types."],"exampleFix":"// before\nexport QW_SEARCHER_FAST_FIELD_CACHE_CAPACITY=\"1 GB\"\n// after (ByteSize accepts compact form, no space)\nexport QW_SEARCHER_FAST_FIELD_CACHE_CAPACITY=\"1GB\"","handlingStrategy":"validation","validationCode":"function validateEnvVar(key, type) {\n  const raw = process.env[key];\n  if (raw === undefined) return true;\n  switch (type) {\n    case 'u64': case 'usize': {\n      const n = Number(raw);\n      return Number.isInteger(n) && n >= 0;\n    }\n    case 'bool': return raw === 'true' || raw === 'false';\n    case 'bytesize': return /^\\d+(B|KB|MB|GB|TB|KiB|MiB|GiB)$/i.test(raw);\n    case 'duration': return /^\\d+(ms|s|m|h|d)$/.test(raw);\n    default: return raw.length > 0;\n  }\n}\n// validateEnvVar('QW_GRPC_MAX_MESSAGE_SIZE', 'bytesize')","typeGuard":"const isPositiveInt = (s) => /^\\d+$/.test(s.trim());","tryCatchPattern":null,"preventionTips":["Print and sanity-check every QW_* env var before launching (`env | grep ^QW_`).","Use exact unit suffixes for size/duration settings (20MB, 30s) with no spaces.","Avoid quotes-inside-values from templating (e.g. QW_X=\"\\\"5\\\"\").","Pin env var values in deployment manifests rather than composing them with shell string operations.","Unset variables you don't intend to override so config-file defaults apply."],"tags":["config","environment-variables","parsing"],"backgroundTag":"invalid-env-var-value","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}