phacility/phabricator · warning · PhutilArgumentUsageException
Specify "--enable" or "--disable", but not both.
Error message
Specify "--enable" or "--disable", but not both.
What it means
PhutilArgumentUsageException thrown by HeraldRuleManagementWorkflow when both --enable and --disable are passed. The two flags map to the same HeraldRuleDisableTransaction with opposite new-values, so passing both is contradictory; the workflow refuses rather than guessing an order.
Source
Thrown at src/applications/herald/management/HeraldRuleManagementWorkflow.php:64
$rule = id(new HeraldRuleQuery())
->setViewer($viewer)
->withIDs(array($rule_id))
->executeOne();
if (!$rule) {
throw new PhutilArgumentUsageException(
pht(
'Unable to load Herald rule with ID or monogram "%s".',
$rule_name));
}
$is_disable = $args->getArg('disable');
$is_enable = $args->getArg('enable');
$xactions = array();
if ($is_disable && $is_enable) {
throw new PhutilArgumentUsageException(
pht(
'Specify "--enable" or "--disable", but not both.'));
} else if ($is_disable || $is_enable) {
$xactions[] = $rule->getApplicationTransactionTemplate()
->setTransactionType(HeraldRuleDisableTransaction::TRANSACTIONTYPE)
->setNewValue($is_disable);
}
if (!$xactions) {
throw new PhutilArgumentUsageException(
pht(
'Use flags to specify at least one edit to apply to the '.
'rule (for example, use "--disable" to disable a rule).'));
}
$herald_phid = id(new PhabricatorHeraldApplication())->getPHID();
$editor = $rule->getApplicationTransactionEditor()View on GitHub (pinned to 5720a38cfe)
Solutions
- Pass exactly one of the two flags: --disable to disable, --enable to enable.
- In scripts, model the state as a single variable and emit one flag: [ "$STATE" = off ] && FLAG=--disable || FLAG=--enable.
- Clear stale shell history edits before re-running the composed command.
Example fix
# before bin/herald rule --rule H1 --enable --disable # after bin/herald rule --rule H1 --disable
Defensive patterns
Strategy: validation
Validate before calling
$is_disable = (bool)$args->getArg('disable');
$is_enable = (bool)$args->getArg('enable');
if ($is_disable && $is_enable) {
// reject before building transactions: exactly one flag allowed
} Type guard
function exactlyOneOf(/* bool ... */ $flags) {
return count(array_filter($flags)) === 1;
} Try / catch
try {
$workflow->execute($args);
} catch (PhutilArgumentUsageException $ex) {
// 'but not both' -> strip one flag and retry; state-changing ops are
// still safe because the workflow refuses before applying anything
} Prevention
- Model enable/disable as one tri-state variable in scripts so both flags can never be emitted together.
- Audit copy-pasted commands for accumulated flags before running them.
When it happens
Trigger: Running 'bin/herald rule --rule H1 --enable --disable'. The check is a simple $is_disable && $is_enable before any transaction is queued.
Common situations: Copy-pasted command lines accumulated flags from a previous invocation; scripts built by concatenating optional flags without mutual exclusion; muscle memory adding --disable while the command already contained --enable.
Related errors
- Specify a rule to edit with "--rule <id|monogram>".
- Use flags to specify at least one edit to apply to the rule
- Specify an object to test rules for with "--object".
- Specify a content type to run rules for. For this object, va
- Specify a device with --device.
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/9b1ee6b83e7222a9.
Report an issue: GitHub.