vectordotdev/vector · error

test name is required

Error message

test name is required

What it means

vdev's `e2e show` command requires a test name when --environments-only is used: it calls self.test.expect("test name is required"). If the user runs the command with the environments-only flag but omits the test argument, the Option is None and the CLI panics with this message instead of printing a usage error. It is a missing-required-CLI-argument guard implemented as an expect.

Solutions

  1. Provide the test name: `cargo vdev e2e show <test> --environments-only`.
  2. Run without --environments-only if you want the general listing handled by exec(self.test.as_ref(), ...), which tolerates a missing name.
  3. Check `cargo vdev e2e show --help` for the expected argument order.
  4. In code, validate in clap (make the arg required_with = "environments_only") or return anyhow::bail!("test name is required with --environments-only") instead of expect.

Example fix

// before
exec_environments_only(&self.test.expect("test name is required"), E2E_TESTS_DIR)
// after
exec_environments_only(
    self.test.as_ref().ok_or_else(|| anyhow!("test name is required with --environments-only"))?,
    E2E_TESTS_DIR,
)
Defensive patterns

Strategy: validation

Validate before calling

# shell wrapper before invoking vdev
if [ "$1" = "--environments-only" ] && [ -z "$2" ]; then
  echo "test name is required with --environments-only" >&2; exit 2
fi

Type guard

fn require_test_name(test: &Option<String>) -> Result<&String> {
    test.as_ref().ok_or_else(|| anyhow!("test name is required with --environments-only"))
}

Prevention

When it happens

Trigger: Running `cargo vdev e2e show --environments-only` without providing a test name, so self.test is None when exec_environments_only dereferences it.

Common situations: Forgetting the test positional after the flag; scripting the command and dropping an argument; assuming --environments-only lists all tests without needing a name.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


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

Appendix: source

Thrown at vdev/src/commands/e2e/show.rs:23

use anyhow::Result;
use clap::Args;

/// Show information about e2e-tests
#[derive(Args, Debug)]
#[command()]
pub struct Cli {
    /// The desired e2e test name
    test: Option<String>,

    /// Show only the available environments (newline separated)
    #[arg(short = 'e', long)]
    environments_only: bool,
}

impl Cli {
    pub fn exec(self) -> Result<()> {
        if self.environments_only {
            exec_environments_only(&self.test.expect("test name is required"), E2E_TESTS_DIR)
        } else {
            exec(self.test.as_ref(), E2E_TESTS_DIR)
        }
    }
}

View on GitHub (pinned to bdb87aeaa4)