hatoo/oha · error · anyhow::Error
--http2 and --http-version are exclusive
Error message
--http2 and --http-version are exclusive
What it means
oha offers two ways to select HTTP/2: the --http2 flag and --http-version 2. Setting both is ambiguous, so the parse_http_version closure bails when is_http2 is true and --http-version is also Some. This is startup-time CLI validation; no request is sent.
Solutions
- Remove --http2 and rely on `--http-version 2` / `2.0`.
- Or remove --http-version and use the bare `--http2` flag.
Example fix
// before oha --http2 --http-version 2.0 https://example.com // after oha --http2 https://example.com
Defensive patterns
Strategy: validation
Validate before calling
let has_http2 = args.contains(&"--http2".to_string());
let has_version = args.iter().any(|a| a.starts_with("--http-version"));
if has_http2 && has_version {
eprintln!("Pass either --http2 or --http-version, not both");
} Try / catch
match run(opts).await {
Err(e) if e.to_string().contains("--http2 and --http-version are exclusive") => {
eprintln!("Drop one of --http2 / --http-version");
}
Err(e) => return Err(e),
Ok(v) => v,
} Prevention
- Standardize on one mechanism (--http-version) in wrapper scripts.
- Assert against the composed argv in CI before running load tests.
- Avoid injecting default --http-version flags into commands that already use --http2.
When it happens
Trigger: Invoking oha with both `--http2` and `--http-version` set to any value (e.g. `--http2 --http-version 2.0`).
Common situations: Scripting oha where a default --http-version flag is injected while --http2 is also passed; users combining examples from different docs.
Related errors
- Invalid AWS credentials format. Expected…
- AWS credentials (--auth) required when using --aws-sigv4
- Your Oha instance has not been built with HTTP/3 support…
- Unknown HTTP version. Valid versions are 0.9, 1.0, 1.1, 2, 3
- Both --cert and --key must be specified
AI-assisted analysis of hatoo/oha@4efba2d113 (2026-09-09).
Data as JSON: /api/errors/11c2fd10795f6305.
Report an issue: GitHub.
Appendix: source
Thrown at src/main.rs:373
}
let access_key = parts[0];
let secret_key = parts[1];
let session_token = opts.aws_session.take();
Some(AwsSignatureConfig::new(
access_key,
secret_key,
&signing_params,
session_token,
)?)
} else {
anyhow::bail!("AWS credentials (--auth) required when using --aws-sigv4");
}
} else {
None
};
let parse_http_version = |is_http2: bool, version: Option<&str>| match (is_http2, version) {
(true, Some(_)) => anyhow::bail!("--http2 and --http-version are exclusive"),
(true, None) => Ok(http::Version::HTTP_2),
(false, Some(http_version)) => match http_version.trim() {
"0.9" => Ok(http::Version::HTTP_09),
"1.0" => Ok(http::Version::HTTP_10),
"1.1" => Ok(http::Version::HTTP_11),
"2.0" | "2" => Ok(http::Version::HTTP_2),
#[cfg(feature = "http3")]
"3.0" | "3" => Ok(http::Version::HTTP_3),
#[cfg(not(feature = "http3"))]
"3.0" | "3" => anyhow::bail!(
"Your Oha instance has not been built with HTTP/3 support. Try recompiling with the feature enabled."
),
_ => anyhow::bail!("Unknown HTTP version. Valid versions are 0.9, 1.0, 1.1, 2, 3"),
},
(false, None) => Ok(http::Version::HTTP_11),
};
let http_version: http::Version = parse_http_version(opts.http2, opts.http_version.as_deref())?;View on GitHub (pinned to 4efba2d113)