{"record":{"id":"f98eafbe2e80cff3","repo":"phacility/phabricator","slug":"select-caches-to-purge-with-all-or-caches","errorCode":null,"errorMessage":"Select caches to purge with \"--all\" or \"--caches\". Available caches are: %s.","messagePattern":"Select caches to purge with \"--all\" or \"--caches\"\\. Available caches are: (.+?)\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php","lineNumber":35,"sourceCode":"            '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];\n        } else {\n          throw new PhutilArgumentUsageException(\n            pht(\n              'Cache purger \"%s\" is not recognized. Available caches '.","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php#L17-L53","documentation":"Thrown by bin/cache purge when neither --all nor --caches is supplied. The workflow refuses to guess which caches to purge, and the message enumerates the available purger keys from PhabricatorCachePurger::getAllPurgers() so you can pick one.","triggerScenarios":"Running 'bin/cache purge' with no flags; or passing --caches with an empty string value (phutil_nonempty_string fails). A misspelled flag like --cache also leaves getArg('caches') null.","commonSituations":"Assuming bare 'purge' defaults to purging everything; typo'd flag names silently ignored by the argument parser; scripts written before the --caches selector existed.","solutions":["Add --all to purge every registered cache: 'bin/cache purge --all'.","Or pass one or more keys from the list printed in the error message: 'bin/cache purge --caches general' (keys are comma/space separated).","Re-run with no flags to make the workflow print the current valid cache key list for your install."],"exampleFix":"// before\n$ bin/cache purge\n// after\n$ bin/cache purge --all","handlingStrategy":"validation","validationCode":"$is_all = (bool)$args->getArg('all');\n$caches = $args->getArg('caches');\nif (!$is_all && !phutil_nonempty_string($caches)) {\n  // default to --all explicitly, or fail fast with guidance:\n  $args->setArg('all', true);\n}\n$valid = array_keys(PhabricatorCachePurger::getAllPurgers());\n// surface $valid to the operator so they can pick a key","typeGuard":null,"tryCatchPattern":"try {\n  $workflow->execute($args);\n} catch (PhutilArgumentUsageException $ex) {\n  fwrite(STDERR, $ex->getMessage().\"\\n\");\n  exit(1);\n}","preventionTips":["Always pass exactly one selector in scripts; never rely on a default.","Validate flag names with --help before scheduling commands.","Treat an empty shell variable as a hard error rather than letting the command run bare."],"tags":["phabricator","cli","cache","argument-validation","required-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}