vectordotdev/vector · error

Could not find environment named

Error message

Could not find environment named {environment:?}

What it means

When generating a compose test, the environment name given (e.g. "default") must exist as a key in the test config's `environments` map. If the lookup returns None, generation bails with this message. It catches wrong or removed environment names before any containers are created.

Solutions

  1. Open tests/integration/<integration>/config.yaml (or .toml) and list the defined environment keys
  2. Use an environment key that exists, commonly "default"
  3. If the environment is missing, add it to the config's environments map
  4. Check `cargo vdev int show` output for supported environments

Example fix

// before
cargo vdev int run aws staging   # config only defines "default"
// after
cargo vdev int run aws default
Defensive patterns

Strategy: validation

Validate before calling

fn env_defined(config_yaml: &str, env: &str) -> bool {
    let cfg: std::collections::HashMap<String, serde_yaml::Value> =
        serde_yaml::from_str(config_yaml).unwrap();
    cfg.get("environments")
        .map(|m| m.get(env).is_some())
        .unwrap_or(false)
}

Prevention

When it happens

Trigger: Calling `ComposeTest::generate` (via `cargo vdev int run <integration> <environment>`) with an environment name not defined in the integration's config (environments map).

Common situations: Passing an environment name like "arm64" or "local" that the integration config does not define; environment removed/renamed in the config file; forgetting the default environment name used by a specific integration.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at vdev/src/testing/integration.rs:102

    compose: Option<Compose>,
    env_config: Environment,
    retries: u8,
    coverage: bool,
}

impl ComposeTest {
    pub(crate) fn generate(
        local_config: ComposeTestLocalConfig,
        test_name: impl Into<String>,
        environment: impl Into<String>,
        retries: u8,
        coverage: bool,
    ) -> Result<ComposeTest> {
        let test_name: String = test_name.into();
        let environment = environment.into();
        let (test_dir, config) = ComposeTestConfig::load(local_config.directory, &test_name)?;
        let Some(mut env_config) = config.environments().get(&environment).cloned() else {
            bail!("Could not find environment named {environment:?}");
        };

        let network_name = format!("vector-integration-tests-{test_name}");
        let compose = Compose::new(test_dir, env_config.clone(), network_name.clone())?;

        // Auto-detect: If shared image exists, use it. Otherwise use per-test image.
        // Shared image: vector-test-runner-1.90:latest (compiled with all-integration-tests)
        // Per-test image: vector-test-runner-clickhouse-1.90:latest (compiled with specific features)
        let shared_image_name = format!(
            "vector-test-runner-{}:latest",
            RustToolchainConfig::rust_version()
        );
        let runner_name = if docker_image_exists(&shared_image_name).unwrap_or(false) {
            info!("Using shared runner image: {shared_image_name}");
            None
        } else {
            info!("Shared runner image not found, will build image for: {test_name}");
            Some(test_name.clone())

View on GitHub (pinned to bdb87aeaa4)