phacility/phabricator · warning · PhutilArgumentUsageException
Specify either --reset or --threshold, not both.
Error message
Specify either --reset or --threshold, not both.
What it means
`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.
Source
Thrown at src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php:36
),
array(
'name' => 'threshold',
'param' => 'threshold',
'help' => pht(
'Prune ngrams present in more than this fraction of '.
'documents. Provide a value between 0.0 and 1.0.'),
),
));
}
public function execute(PhutilArgumentParser $args) {
$min_documents = 4096;
$is_reset = $args->getArg('reset');
$threshold = $args->getArg('threshold');
if ($is_reset && $threshold !== null) {
throw new PhutilArgumentUsageException(
pht('Specify either --reset or --threshold, not both.'));
}
if (!$is_reset && $threshold === null) {
throw new PhutilArgumentUsageException(
pht('Specify either --reset or --threshold.'));
}
if (!$is_reset) {
if (!is_numeric($threshold)) {
throw new PhutilArgumentUsageException(
pht('Specify a numeric threshold between 0 and 1.'));
}
$threshold = (double)$threshold;
if ($threshold <= 0 || $threshold >= 1) {
throw new PhutilArgumentUsageException(
pht('Threshold must be greater than 0.0 and less than 1.0.'));View on GitHub (pinned to 5720a38cfe)
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
Example fix
# before bin/search ngrams --reset --threshold 0.5 # after bin/search ngrams --threshold 0.5
Defensive patterns
Strategy: validation
Validate before calling
$isReset = !empty($args['reset']);
$threshold = $args['threshold'] ?? null;
if ($isReset && $threshold !== null) {
// pick one mode before executing; never pass both
} Prevention
- 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
When it happens
Trigger: `bin/search ngrams --reset --threshold 0.5`.
Common situations: Copy-pasting a documented example and leaving --reset in; scripts merging flag sets from different invocations.
Related errors
- You can not use query constraint flags (like "--version", "-
- Specify either --reset or --threshold.
- Specify a numeric threshold between 0 and 1.
- Threshold must be greater than 0.0 and less than 1.0.
- Specify a device with --device.
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/5a200f8e231c8b33.
Report an issue: GitHub.