{"record":{"id":"df2e14fb3595aee7","repo":"phacility/phabricator","slug":"threshold-must-be-greater-than-0-0-and-less-than-1","errorCode":null,"errorMessage":"Threshold must be greater than 0.0 and less than 1.0.","messagePattern":"Threshold must be greater than 0\\.0 and less than 1\\.0\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php","lineNumber":53,"sourceCode":"    if ($is_reset && $threshold !== null) {\n      throw new PhutilArgumentUsageException(\n        pht('Specify either --reset or --threshold, not both.'));\n    }\n\n    if (!$is_reset && $threshold === null) {\n      throw new PhutilArgumentUsageException(\n        pht('Specify either --reset or --threshold.'));\n    }\n\n    if (!$is_reset) {\n      if (!is_numeric($threshold)) {\n        throw new PhutilArgumentUsageException(\n          pht('Specify a numeric threshold between 0 and 1.'));\n      }\n\n      $threshold = (double)$threshold;\n      if ($threshold <= 0 || $threshold >= 1) {\n        throw new PhutilArgumentUsageException(\n          pht('Threshold must be greater than 0.0 and less than 1.0.'));\n      }\n    }\n\n    $all_objects = id(new PhutilClassMapQuery())\n      ->setAncestorClass('PhabricatorFerretInterface')\n      ->execute();\n\n    foreach ($all_objects as $object) {\n      $engine = $object->newFerretEngine();\n      $conn = $object->establishConnection('w');\n      $display_name = get_class($object);\n\n      if ($is_reset) {\n        echo tsprintf(\n          \"%s\\n\",\n          pht(\n            'Resetting common ngrams for \"%s\".',","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php#L35-L71","documentation":"After the numeric cast, `bin/search ngrams --threshold` requires the value to be strictly inside the open interval (0, 1): values <= 0 or >= 1 throw. The threshold is the maximum fraction of documents an ngram may appear in before being treated as a common ngram (stopword), so 0 and 1 are rejected extremes. Note tables with fewer than 4096 documents ($min_documents) are skipped entirely.","triggerScenarios":"`--threshold 1`, `--threshold 0`, `--threshold 1.5`, negative values, or percentage-style values like 5 (intending 5%).","commonSituations":"Assuming a 0-100 percent scale and passing 5 instead of 0.05; copying values from unrelated tooling; attempting 1.0 to 'include everything'.","solutions":["Rescale percentages to fractions: 5% becomes 0.05","Pick a value strictly between 0 and 1, typically small (0.01-0.2) for large corpora","Remember engines with under 4096 documents are skipped regardless of threshold"],"exampleFix":"# before (intended \"5 percent\")\nbin/search ngrams --threshold 5\n\n# after\nbin/search ngrams --threshold 0.05","handlingStrategy":"validation","validationCode":"if (!is_numeric($threshold) || (double)$threshold <= 0 || (double)$threshold >= 1) {\n  // reject: threshold must be strictly between 0.0 and 1.0\n}","typeGuard":"function isValidNgramThreshold($t) {\n  return is_string($t) && is_numeric($t)\n    && (double)$t > 0.0 && (double)$t < 1.0;\n}","tryCatchPattern":null,"preventionTips":["Think in fractions (0.05), never percentages (5)","Keep thresholds in one documented place in your tooling","Remember sub-4096-document tables are skipped, so small installs need no threshold tuning"],"tags":["cli","ngrams","usage-error","range-check"],"backgroundTag":"value-out-of-range","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}