{"record":{"id":"77850a1fe768f5b5","repo":"tursodatabase/turso","slug":"documents-must-be-positive","errorCode":null,"errorMessage":"documents must be positive","messagePattern":"documents must be positive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"perf/memory/src/fts.rs","lineNumber":270,"sourceCode":"            while let Some(worker) = workers.join_next().await {\n                let batch = worker??;\n                result.queries += batch.queries;\n                result.rows += batch.rows;\n                result.id_sum += batch.id_sum;\n            }\n            Ok(result)\n        }\n        .await;\n        if result.is_err() {\n            workers.shutdown().await;\n        }\n        result\n    }\n}\n\nimpl FtsConfig {\n    pub fn validate(&self) -> Result<()> {\n        ensure!(self.documents > 0, \"documents must be positive\");\n        ensure!(\n            self.corpus\n                .cache_pages\n                .is_none_or(|pages| (200..=i32::MAX as usize).contains(&pages)),\n            \"cache pages must be between 200 and i32::MAX\"\n        );\n        ensure!(self.connections > 0, \"connections must be positive\");\n        ensure!(\n            self.execution.batches() > 0,\n            \"queries or transactions must be positive\"\n        );\n        ensure!(\n            self.execution.queries_per_batch() > 0,\n            \"queries per transaction must be positive\"\n        );\n        ensure!(\n            !matches!(self.state, QueryState::First)\n                || (self.execution.batches() == 1 && self.execution.queries_per_batch() == 1),","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/tursodatabase/turso/blob/492c4a71cd7c2649e7df83da1471b74f4b1c7aa9/perf/memory/src/fts.rs#L252-L288","documentation":"FtsConfig::validate() rejects configurations where documents is zero. The benchmark needs at least one document to build an FTS index and produce meaningful memory numbers, so a non-positive document count fails validation before any benchmark work starts.","triggerScenarios":"Constructing FtsConfig or passing CLI args such that documents == 0 (e.g. --documents 0 or a computed default of 0).","commonSituations":"Typo on the command line; shell variable expansion yielding empty/0; programmatic config where documents comes from an unset or zero-valued parameter.","solutions":["Pass a positive document count, e.g. --documents 10000","If documents is computed, check the input value before building FtsConfig","Fall back to a sane default when the argument is missing or zero"],"exampleFix":"// before\ntursodb-memory-fts --documents 0\n// after\ntursodb-memory-fts --documents 10000","handlingStrategy":"validation","validationCode":"if documents == 0 { return Err(anyhow!(\"documents must be > 0\")); }\nlet config = FtsConfig { documents, .. };\nconfig.validate()?;","typeGuard":null,"tryCatchPattern":"match config.validate() {\n    Err(e) if e.to_string().contains(\"documents must be positive\") => {\n        // fall back to a default document count\n    }\n    r => r?,\n}","preventionTips":["Never pass raw CLI strings without parsing into a positive number","Default unset document counts to a known-good value","Call FtsConfig::validate() early in main, before any setup"],"tags":["configuration","validation","benchmark","fts"],"backgroundTag":"invalid-argument-value","analyzedSha":"492c4a71cd7c2649e7df83da1471b74f4b1c7aa9","analyzedAt":"2026-09-13T18:13:59.796Z","contentChangedAt":"2026-09-13T18:13:59.796Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}