{"record":{"id":"2e7c292c9b4019f0","repo":"tursodatabase/turso","slug":"seconds-must-be-finite-and-positive","errorCode":null,"errorMessage":"seconds must be finite and positive","messagePattern":"seconds must be finite and positive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"perf/fts/src/main.rs","lineNumber":102,"sourceCode":"                \"need at least one query per connection\"\n            );\n            ensure!(\n                !matches!(args.state, QueryState::First) || queries == args.connections,\n                \"first-query latency requires one query per connection\"\n            );\n            (queries, 0.0)\n        }\n        Benchmark::Throughput => {\n            ensure!(\n                args.queries.is_none(),\n                \"--queries requires --benchmark search\"\n            );\n            ensure!(\n                matches!(args.state, QueryState::Warm),\n                \"throughput requires --state warm\"\n            );\n            let seconds = args.seconds.unwrap_or(5.0);\n            ensure!(\n                seconds.is_finite() && seconds > 0.0,\n                \"seconds must be finite and positive\"\n            );\n            (0, seconds)\n        }\n    };\n    #[cfg(all(feature = \"flamegraph\", any(target_os = \"linux\", target_os = \"macos\")))]\n    let profiled = args.flamegraph.is_some();\n    #[cfg(not(all(feature = \"flamegraph\", any(target_os = \"linux\", target_os = \"macos\"))))]\n    let profiled = false;\n    #[cfg(all(feature = \"flamegraph\", any(target_os = \"linux\", target_os = \"macos\")))]\n    if let Some(directory) = &args.flamegraph {\n        std::fs::create_dir(directory)?;\n    }\n    let mut output = stdout().lock();\n    writeln!(\n        output,\n        \"benchmark,engine,mode,state,documents,connections,queries,run,query,seconds,rows,id_sum,debug_assertions,requested_queries,min_seconds,p50_ms,p95_ms,p99_ms,profiled\"","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/tursodatabase/turso/blob/8d4a589f8d13ac184700d2a8f724f27e1995be3b/perf/fts/src/main.rs#L84-L120","documentation":"The throughput duration must be a finite, strictly positive number of seconds. ensure! at perf/fts/src/main.rs:102 validates the value after applying the 5.0 default, rejecting NaN, infinity, zero, and negatives, because a non-positive or non-finite duration makes the timing loop meaningless or infinite.","triggerScenarios":"Passing --seconds 0, --seconds -5, --seconds nan, --seconds inf, or any value that parses to a non-finite/non-positive f64 while in throughput mode.","commonSituations":"Shell variables interpolating to empty/zero; mis-typed units like --seconds 0.0; programmatic CLI construction with uninitialized or divided-by-zero floats.","solutions":["Pass a positive finite --seconds value, e.g. --seconds 5","Omit --seconds to use the built-in 5.0 second default","Fix the upstream script/variable that computes the duration"],"exampleFix":"// before\nfts-bench --benchmark throughput --state warm --seconds 0\n// after\nfts-bench --benchmark throughput --state warm --seconds 5","handlingStrategy":"validation","validationCode":"let s: f64 = seconds.parse()?; if !s.is_finite() || s <= 0.0 { panic!(\"--seconds must be finite and > 0\"); }","typeGuard":"fn valid_seconds(v: f64) -> bool { v.is_finite() && v > 0.0 }","tryCatchPattern":null,"preventionTips":["Guard interpolated shell variables before passing them as flag values","Prefer omitting --seconds to use the 5s default for standard runs","Never pass raw float strings from user input without parsing/checking"],"tags":["cli","argument-validation","benchmark","numeric"],"backgroundTag":"invalid-argument-value","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"}