{"record":{"id":"5a200f8e231c8b33","repo":"phacility/phabricator","slug":"specify-either-reset-or-threshold-not-both","errorCode":null,"errorMessage":"Specify either --reset or --threshold, not both.","messagePattern":"Specify either --reset or --threshold, not both\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php","lineNumber":36,"sourceCode":"          ),\n          array(\n            'name' => 'threshold',\n            'param' => 'threshold',\n            'help' => pht(\n              '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.'));","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php#L18-L54","documentation":"`bin/search ngrams` has two exclusive modes: --reset clears all common-ngram records and --threshold N prunes ngrams appearing in more than a fraction N of documents. Passing both at once (the code checks $is_reset && $threshold !== null) is rejected because the operations would contradict each other.","triggerScenarios":"`bin/search ngrams --reset --threshold 0.5`.","commonSituations":"Copy-pasting a documented example and leaving --reset in; scripts merging flag sets from different invocations.","solutions":["Choose one mode: `bin/search ngrams --threshold 0.05` to prune, or `bin/search ngrams --reset` to clear","Run `bin/search help ngrams` to review the two modes"],"exampleFix":"# before\nbin/search ngrams --reset --threshold 0.5\n\n# after\nbin/search ngrams --threshold 0.5","handlingStrategy":"validation","validationCode":"$isReset = !empty($args['reset']);\n$threshold = $args['threshold'] ?? null;\nif ($isReset && $threshold !== null) {\n  // pick one mode before executing; never pass both\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read `bin/search help ngrams` before combining flags","Do not merge flag sets from different example invocations","Remember ngrams is an advanced workflow; default to not running it"],"tags":["cli","ngrams","usage-error","argument-conflict"],"backgroundTag":"mutually-exclusive-cli-flags","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}