{"record":{"id":"eb7b9f521d287d50","repo":"tursodatabase/turso","slug":"connections-must-be-positive-main","errorCode":null,"errorMessage":"connections must be positive","messagePattern":"connections must be positive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"perf/fts/src/main.rs","lineNumber":53,"sourceCode":"    targets: Vec<Target>,\n    #[arg(long, default_value_t = 1)]\n    connections: usize,\n    #[arg(\n        long,\n        value_enum,\n        value_delimiter = ',',\n        default_value = \"rare,common,and,or,phrase,ranked\"\n    )]\n    cases: Vec<QueryCase>,\n    #[cfg(all(feature = \"flamegraph\", any(target_os = \"linux\", target_os = \"macos\")))]\n    #[arg(long)]\n    flamegraph: Option<std::path::PathBuf>,\n}\n\nfn main() -> Result<()> {\n    let args = Args::parse();\n    ensure!(args.runs > 0, \"runs must be positive\");\n    ensure!(args.connections > 0, \"connections must be positive\");\n    eprintln!(\"bundled SQLite version: {}\", rusqlite::version());\n    let runtime = match args.benchmark {\n        Benchmark::Search => tokio::runtime::Builder::new_current_thread()\n            .enable_all()\n            .build()?,\n        Benchmark::Throughput => tokio::runtime::Builder::new_multi_thread()\n            .worker_threads(args.connections)\n            .max_blocking_threads(args.connections)\n            .enable_all()\n            .build()?,\n    };\n    runtime.block_on(run(args))\n}\n\nasync fn run(mut args: Args) -> Result<()> {\n    let (query_limit, min_seconds) = match args.benchmark {\n        Benchmark::Search => {\n            ensure!(","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/tursodatabase/turso/blob/8d4a589f8d13ac184700d2a8f724f27e1995be3b/perf/fts/src/main.rs#L35-L71","documentation":"Command-line argument validation in main: the --connections option was given a value of zero, which makes no sense for a benchmark that runs queries across N concurrent connections. This is a clap-adjacent ensure! guard rejecting a non-positive --connections value; pass 1 or more.","triggerScenarios":"Invoking the perf/fts binary with `--connections 0` or a negative value.","commonSituations":"A shell variable holding the connection count defaulting to 0, or a config/script bug computing thread counts.","solutions":["Re-run with `--connections` set to a positive integer (e.g. `--connections 4`).","Fix the source of the connection count (env var/config) to be >= 1.","Add a clap value_parser range so invalid values are rejected at parse time with a usage message."],"exampleFix":"// before\nperf-fts --connections 0\n// after\nperf-fts --connections 4","handlingStrategy":"validation","validationCode":"if connections <= 0 { eprintln!(\"--connections must be a positive integer\"); std::process::exit(2); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check shell variables feeding --connections for 0/empty defaults","Use clap range parsing to reject non-positive values at parse time","Keep wrapper scripts setting explicit positive defaults"],"tags":["cli","validation","benchmark"],"backgroundTag":"invalid-cli-argument","analyzedSha":"8d4a589f8d13ac184700d2a8f724f27e1995be3b","analyzedAt":"2026-09-20T13:18:14.658Z","contentChangedAt":"2026-09-20T13:18:14.658Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}