{"record":{"id":"89f48619617e635c","repo":"vectordotdev/vector","slug":"could-not-find-environment-named-environment","errorCode":null,"errorMessage":"Could not find environment named {environment:?}","messagePattern":"Could not find environment named (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vdev/src/testing/integration.rs","lineNumber":102,"sourceCode":"    compose: Option<Compose>,\n    env_config: Environment,\n    retries: u8,\n    coverage: bool,\n}\n\nimpl ComposeTest {\n    pub(crate) fn generate(\n        local_config: ComposeTestLocalConfig,\n        test_name: impl Into<String>,\n        environment: impl Into<String>,\n        retries: u8,\n        coverage: bool,\n    ) -> Result<ComposeTest> {\n        let test_name: String = test_name.into();\n        let environment = environment.into();\n        let (test_dir, config) = ComposeTestConfig::load(local_config.directory, &test_name)?;\n        let Some(mut env_config) = config.environments().get(&environment).cloned() else {\n            bail!(\"Could not find environment named {environment:?}\");\n        };\n\n        let network_name = format!(\"vector-integration-tests-{test_name}\");\n        let compose = Compose::new(test_dir, env_config.clone(), network_name.clone())?;\n\n        // Auto-detect: If shared image exists, use it. Otherwise use per-test image.\n        // Shared image: vector-test-runner-1.90:latest (compiled with all-integration-tests)\n        // Per-test image: vector-test-runner-clickhouse-1.90:latest (compiled with specific features)\n        let shared_image_name = format!(\n            \"vector-test-runner-{}:latest\",\n            RustToolchainConfig::rust_version()\n        );\n        let runner_name = if docker_image_exists(&shared_image_name).unwrap_or(false) {\n            info!(\"Using shared runner image: {shared_image_name}\");\n            None\n        } else {\n            info!(\"Shared runner image not found, will build image for: {test_name}\");\n            Some(test_name.clone())","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/vdev/src/testing/integration.rs#L84-L120","documentation":"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.","triggerScenarios":"Calling `ComposeTest::generate` (via `cargo vdev int run <integration> <environment>`) with an environment name not defined in the integration's config (environments map).","commonSituations":"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.","solutions":["Open tests/integration/<integration>/config.yaml (or .toml) and list the defined environment keys","Use an environment key that exists, commonly \"default\"","If the environment is missing, add it to the config's environments map","Check `cargo vdev int show` output for supported environments"],"exampleFix":"// before\ncargo vdev int run aws staging   # config only defines \"default\"\n// after\ncargo vdev int run aws default","handlingStrategy":"validation","validationCode":"fn env_defined(config_yaml: &str, env: &str) -> bool {\n    let cfg: std::collections::HashMap<String, serde_yaml::Value> =\n        serde_yaml::from_str(config_yaml).unwrap();\n    cfg.get(\"environments\")\n        .map(|m| m.get(env).is_some())\n        .unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read the integration's config file to confirm environment keys before invoking","Prefer \"default\" unless the config explicitly defines another environment name","After renaming environments in config, grep docs/scripts for the old name"],"tags":["rust","integration-tests","configuration","docker-compose"],"backgroundTag":"invalid-config-value","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"}