vectordotdev/vector · error

Required environment variables are not set

Error message

Required environment variables are not set: {missing}

What it means

`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.

Solutions

  1. Export each variable listed in the error message, e.g. `export AWS_ACCESS_KEY_ID=...`
  2. Source your env file: `set -a; source .env; set +a` or use direnv
  3. In CI, configure the secrets as environment variables on the job
  4. Remove the variable from the environment's required list only if it is genuinely not needed

Example fix

// before
export AWS_ACCESS_KEY_ID=...   # AWS_SECRET_ACCESS_KEY missing
// after
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
Defensive patterns

Strategy: validation

Validate before calling

const REQUIRED: &[&str] = &["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"];
let missing: Vec<_> = REQUIRED.iter().filter(|v| std::env::var(v).is_err()).collect();
assert!(missing.is_empty(), "missing: {:?}", missing);

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16). Data as JSON: /api/errors/87cbaaf07c325243. Report an issue: GitHub.

Appendix: source

Thrown at vdev/src/testing/config.rs:285

        Self::collect_all_dir(&tests_dir, &mut configs, use_config_subdir)?;

        Ok(configs)
    }

    /// Ensure that all passthrough environment variables are set.
    pub fn check_required(&self) -> Result<()> {
        let missing: Vec<_> = self
            .env
            .iter()
            .chain(self.runner.env.iter())
            .filter_map(|(key, value)| value.is_none().then_some(key))
            .filter(|var| env::var(var).is_err())
            .collect();
        if missing.is_empty() {
            Ok(())
        } else {
            let missing = missing.into_iter().join(", ");
            bail!("Required environment variables are not set: {missing}");
        }
    }
}

View on GitHub (pinned to bdb87aeaa4)