{"record":{"id":"4045cf0bacd564ed","repo":"phacility/phabricator","slug":"specify-either-reset-or-threshold","errorCode":null,"errorMessage":"Specify either --reset or --threshold.","messagePattern":"Specify either --reset or --threshold\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php","lineNumber":41,"sourceCode":"              'Prune ngrams present in more than this fraction of '.\n              'documents. Provide a value between 0.0 and 1.0.'),\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $min_documents = 4096;\n\n    $is_reset = $args->getArg('reset');\n    $threshold = $args->getArg('threshold');\n\n    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')","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php#L23-L59","documentation":"`bin/search ngrams` requires exactly one of --reset or --threshold. Invoked with neither, it has no defined behavior (the workflow recomputes ngram stopwords per Ferret engine and must know the strategy), so it fails with this usage exception.","triggerScenarios":"Bare `bin/search ngrams` with no flags.","commonSituations":"Exploring the CLI expecting a status report; scripts where the flag argument was dropped during refactoring.","solutions":["Add a threshold: `bin/search ngrams --threshold 0.05` (a fraction strictly between 0.0 and 1.0)","Or reset: `bin/search ngrams --reset`","Check `bin/search help ngrams` for the intended workflow"],"exampleFix":"# before\nbin/search ngrams\n\n# after\nbin/search ngrams --threshold 0.05","handlingStrategy":"validation","validationCode":"$isReset = !empty($args['reset']);\n$threshold = $args['threshold'] ?? null;\nif (!$isReset && $threshold === null) {\n  // require exactly one of --reset / --threshold before invoking\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass exactly one mode flag to bin/search ngrams","Assert non-empty flag arguments when building CLI commands from variables"],"tags":["cli","ngrams","usage-error","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}