vectordotdev/vector · error

Requested environment

Error message

Requested environment {environment:?} does not match active one {active:?}

What it means

Thrown by `cargo vdev compose_tests test` (exec) when the caller requests a specific integration environment that does not match the currently active environment for that integration (found via find_active_environment_for_integration). Only one environment may be active per integration at a time, so a mismatched request is rejected.

Solutions

  1. Run without the --environment flag so the active environment is used automatically.
  2. Deactivate the current environment for the integration, then activate the requested one and re-run.
  3. Run `cargo vdev int show` to inspect which environment is active.
  4. Pass the exact active environment name (match the debug output 'Active environment').

Example fix

// before
cargo vdev compose_tests test gcp-cloud-storage --environment aws-integration-tests
// after
cargo vdev int deactivate
cargo vdev int activate gcp
cargo vdev compose_tests test gcp-cloud-storage
Defensive patterns

Strategy: validation

Validate before calling

if let Some(req) = requested_environment { assert_eq!(req, active_environment.expect("no active environment"), "requested environment must match active one"); }

Type guard

fn env_matches(requested: &str, active: Option<&String>) -> bool { matches!(active, Some(a) if a == requested) || active.is_none() }

Try / catch

match result { Err(e) if e.to_string().starts_with("Requested environment") => { eprintln!("Deactivate current env or drop --environment flag"); } Err(e) => return Err(e), Ok(v) => v }

Prevention

When it happens

Trigger: Calling the test command with `--environment <name>` (or Some(environment)) while a different environment is active for the integration directory, i.e. environment != active in the match.

Common situations: Happens when switching between cloud integration setups (e.g. AWS vs GCP) without deactivating the previous environment, or when CI/dev machines have a stale active environment configured.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at vdev/src/commands/compose_tests/test.rs:30

pub fn exec(
    local_config: ComposeTestLocalConfig,
    integration: &str,
    environment: Option<&String>,
    retries: u8,
    args: &[String],
    coverage: bool,
) -> Result<()> {
    let (_test_dir, config) = ComposeTestConfig::load(local_config.directory, integration)?;
    let envs = config.environments();

    let active =
        find_active_environment_for_integration(local_config.directory, integration, &config)?;
    debug!("Active environment: {active:#?}");

    let environments: Box<dyn Iterator<Item = &String>> = match (environment, &active) {
        (Some(environment), Some(active)) if environment != active => {
            bail!("Requested environment {environment:?} does not match active one {active:?}")
        }
        (Some(environment), _) => Box::new(once(environment)),
        (None, Some(active)) => Box::new(once(active)),
        (None, None) => Box::new(envs.keys()),
    };

    if coverage {
        clear_coverage();
    }

    let mut ran_environments = Vec::new();
    for environment in environments {
        run_environment(
            local_config,
            integration,
            environment,
            retries,
            args,

View on GitHub (pinned to bdb87aeaa4)