{"record":{"id":"11c2fd10795f6305","repo":"hatoo/oha","slug":"http2-and-http-version-are-exclusive","errorCode":null,"errorMessage":"--http2 and --http-version are exclusive","messagePattern":"--http2 and --http-version are exclusive","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/main.rs","lineNumber":373,"sourceCode":"            }\n            let access_key = parts[0];\n            let secret_key = parts[1];\n            let session_token = opts.aws_session.take();\n            Some(AwsSignatureConfig::new(\n                access_key,\n                secret_key,\n                &signing_params,\n                session_token,\n            )?)\n        } else {\n            anyhow::bail!(\"AWS credentials (--auth) required when using --aws-sigv4\");\n        }\n    } else {\n        None\n    };\n\n    let parse_http_version = |is_http2: bool, version: Option<&str>| match (is_http2, version) {\n        (true, Some(_)) => anyhow::bail!(\"--http2 and --http-version are exclusive\"),\n        (true, None) => Ok(http::Version::HTTP_2),\n        (false, Some(http_version)) => match http_version.trim() {\n            \"0.9\" => Ok(http::Version::HTTP_09),\n            \"1.0\" => Ok(http::Version::HTTP_10),\n            \"1.1\" => Ok(http::Version::HTTP_11),\n            \"2.0\" | \"2\" => Ok(http::Version::HTTP_2),\n            #[cfg(feature = \"http3\")]\n            \"3.0\" | \"3\" => Ok(http::Version::HTTP_3),\n            #[cfg(not(feature = \"http3\"))]\n            \"3.0\" | \"3\" => anyhow::bail!(\n                \"Your Oha instance has not been built with HTTP/3 support. Try recompiling with the feature enabled.\"\n            ),\n            _ => anyhow::bail!(\"Unknown HTTP version. Valid versions are 0.9, 1.0, 1.1, 2, 3\"),\n        },\n        (false, None) => Ok(http::Version::HTTP_11),\n    };\n\n    let http_version: http::Version = parse_http_version(opts.http2, opts.http_version.as_deref())?;","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/hatoo/oha/blob/4efba2d113d165aaaf7533f5d2893e7cc57ebfc1/src/main.rs#L355-L391","documentation":"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.","triggerScenarios":"Invoking oha with both `--http2` and `--http-version` set to any value (e.g. `--http2 --http-version 2.0`).","commonSituations":"Scripting oha where a default --http-version flag is injected while --http2 is also passed; users combining examples from different docs.","solutions":["Remove --http2 and rely on `--http-version 2` / `2.0`.","Or remove --http-version and use the bare `--http2` flag."],"exampleFix":"// before\noha --http2 --http-version 2.0 https://example.com\n// after\noha --http2 https://example.com","handlingStrategy":"validation","validationCode":"let has_http2 = args.contains(&\"--http2\".to_string());\nlet has_version = args.iter().any(|a| a.starts_with(\"--http-version\"));\nif has_http2 && has_version {\n    eprintln!(\"Pass either --http2 or --http-version, not both\");\n}","typeGuard":null,"tryCatchPattern":"match run(opts).await {\n    Err(e) if e.to_string().contains(\"--http2 and --http-version are exclusive\") => {\n        eprintln!(\"Drop one of --http2 / --http-version\");\n    }\n    Err(e) => return Err(e),\n    Ok(v) => v,\n}","preventionTips":["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."],"tags":["cli","http2","conflicting-options"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"4efba2d113d165aaaf7533f5d2893e7cc57ebfc1","analyzedAt":"2026-09-09T16:24:23.306Z","contentChangedAt":"2026-09-09T16:24:23.306Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}