{"record":{"id":"87cbaaf07c325243","repo":"vectordotdev/vector","slug":"required-environment-variables-are-not-set-missing","errorCode":null,"errorMessage":"Required environment variables are not set: {missing}","messagePattern":"Required environment variables are not set: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vdev/src/testing/config.rs","lineNumber":285,"sourceCode":"        Self::collect_all_dir(&tests_dir, &mut configs, use_config_subdir)?;\n\n        Ok(configs)\n    }\n\n    /// Ensure that all passthrough environment variables are set.\n    pub fn check_required(&self) -> Result<()> {\n        let missing: Vec<_> = self\n            .env\n            .iter()\n            .chain(self.runner.env.iter())\n            .filter_map(|(key, value)| value.is_none().then_some(key))\n            .filter(|var| env::var(var).is_err())\n            .collect();\n        if missing.is_empty() {\n            Ok(())\n        } else {\n            let missing = missing.into_iter().join(\", \");\n            bail!(\"Required environment variables are not set: {missing}\");\n        }\n    }\n}\n","sourceCodeStart":267,"sourceCodeEnd":289,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/vdev/src/testing/config.rs#L267-L289","documentation":"`check_required` validates that every environment variable declared in the integration test config is set before starting containers. If any are missing, it collects the names and bails with a joined list. This ensures integration environments have the credentials/settings they need up front.","triggerScenarios":"Calling `ComposeTest::start()` (or the config's `check_required()`) when at least one env var listed in the environment's `required` section is unset in the shell.","commonSituations":"Forgetting to export AWS credentials for the aws integration; running integration tests in CI without secret injection; switching shells where env vars were set only in another profile.","solutions":["Export each variable listed in the error message, e.g. `export AWS_ACCESS_KEY_ID=...`","Source your env file: `set -a; source .env; set +a` or use direnv","In CI, configure the secrets as environment variables on the job","Remove the variable from the environment's required list only if it is genuinely not needed"],"exampleFix":"// before\nexport AWS_ACCESS_KEY_ID=...   # AWS_SECRET_ACCESS_KEY missing\n// after\nexport AWS_ACCESS_KEY_ID=...\nexport AWS_SECRET_ACCESS_KEY=...","handlingStrategy":"validation","validationCode":"const REQUIRED: &[&str] = &[\"AWS_ACCESS_KEY_ID\", \"AWS_SECRET_ACCESS_KEY\"];\nlet missing: Vec<_> = REQUIRED.iter().filter(|v| std::env::var(v).is_err()).collect();\nassert!(missing.is_empty(), \"missing: {:?}\", missing);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a .env file (gitignored) with all required integration variables and source it before testing","Use direnv or similar to load variables automatically per directory","In CI, wire all required secrets into the job environment","Run the integration check early in scripts to fail fast before builds"],"tags":["rust","environment-variables","integration-tests","configuration"],"backgroundTag":"missing-env-var","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}