{"record":{"id":"f55a30e7fb35218a","repo":"phacility/phabricator","slug":"specify-either-all-or-caches-not-both","errorCode":null,"errorMessage":"Specify either \"--all\" or \"--caches\", not both.","messagePattern":"Specify either \"--all\" or \"--caches\", not both\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php","lineNumber":31,"sourceCode":"            'name' => 'all',\n            'help' => pht('Purge all caches.'),\n          ),\n          array(\n            'name' => 'caches',\n            'param' => 'keys',\n            'help' => pht('Purge a specific set of caches.'),\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $all_purgers = PhabricatorCachePurger::getAllPurgers();\n\n    $is_all = $args->getArg('all');\n    $key_list = $args->getArg('caches');\n\n    if ($is_all && phutil_nonempty_string($key_list)) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Specify either \"--all\" or \"--caches\", not both.'));\n    } else if (!$is_all && !phutil_nonempty_string($key_list)) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Select caches to purge with \"--all\" or \"--caches\". Available '.\n          'caches are: %s.',\n          implode(', ', array_keys($all_purgers))));\n    }\n\n    if ($is_all) {\n      $purgers = $all_purgers;\n    } else {\n      $key_list = preg_split('/[\\s,]+/', $key_list);\n      $purgers = array();\n      foreach ($key_list as $key) {\n        if (isset($all_purgers[$key])) {\n          $purgers[$key] = $all_purgers[$key];","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php#L13-L49","documentation":"Thrown by Phabricator's cache purge management workflow (bin/cache purge) when the command line supplies both --all and --caches. The workflow either purges every registered cache or a selected subset; the two selectors are mutually exclusive by design, so combining them aborts before any cache is touched.","triggerScenarios":"Running 'bin/cache purge --all --caches general' (or any invocation where getArg('all') is truthy AND getArg('caches') is a non-empty string). Also reachable from PHP by constructing the workflow and passing both arguments.","commonSituations":"Shell scripts that append --caches while a hardcoded --all remains in the command; copy-pasting example invocations that include both flags; wrapper scripts that always pass --all plus a user-supplied cache list.","solutions":["Re-run with exactly one selector: 'bin/cache purge --all' or 'bin/cache purge --caches general'.","If wrapping the workflow in PHP, clear one flag before execute(): pass either all=true with caches=null, or caches set with all=false.","Audit cron/systemd entries and deploy scripts for stale --all flags combined with newer --caches flags."],"exampleFix":"// before\n$ bin/cache purge --all --caches general\n// after\n$ bin/cache purge --all","handlingStrategy":"validation","validationCode":"// Before invoking the workflow, ensure the selectors are exclusive:\n$is_all = (bool)$args->getArg('all');\n$caches = $args->getArg('caches');\nif ($is_all) {\n  $args->setArg('caches', null); // drop --caches when --all is set\n}\nif ($is_all && phutil_nonempty_string($caches)) {\n  // refuse early with your own message instead of the workflow's exception\n  throw new InvalidArgumentException('Use --all or --caches, not both.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  $workflow->execute($args);\n} catch (PhutilArgumentUsageException $ex) {\n  echo tsprintf(\"%s\\n\", $ex->getMessage());\n  echo $args->printUsageException($ex);\n  exit(1);\n}","preventionTips":["Build purge commands from a single selector variable so both flags can never be emitted together.","In wrapper scripts, explicitly null out one flag before delegating.","Smoke-test cron entries after adding new flags to purge commands."],"tags":["phabricator","cli","cache","argument-validation","mutually-exclusive-flags"],"backgroundTag":"cli-argument-conflict","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}