{"record":{"id":"bfee588af0623355","repo":"phacility/phabricator","slug":"specify-a-content-type-to-run-rules-for-for-this","errorCode":null,"errorMessage":"Specify a content type to run rules for. For this object, valid content types are: %s.","messagePattern":"Specify a content type to run rules for\\. For this object, valid content types are: (.+?)\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/herald/management/HeraldTestManagementWorkflow.php","lineNumber":73,"sourceCode":"      if (!$adapter->isTestAdapterForObject($object)) {\n        continue;\n      }\n\n      if (!$adapter->isAvailableToUser($viewer)) {\n        continue;\n      }\n\n      $display_adapters[$key] = $adapter;\n\n      if ($adapter->canCreateTestAdapterForObject($object)) {\n        $can_select[$key] = $adapter;\n      }\n    }\n\n\n    $content_type = $args->getArg('type');\n    if (!strlen($content_type)) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Specify a content type to run rules for. For this object, valid '.\n          'content types are: %s.',\n          implode(', ', array_keys($can_select))));\n    }\n\n    if (!isset($can_select[$content_type])) {\n      if (!isset($display_adapters[$content_type])) {\n        throw new PhutilArgumentUsageException(\n          pht(\n            'Specify a content type to run rules for. The specified content '.\n            'type (\"%s\") is not valid. For this object, valid content types '.\n            'are: %s.',\n            $content_type,\n            implode(', ', array_keys($can_select))));\n      } else {\n        throw new PhutilArgumentUsageException(\n          pht(","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/herald/management/HeraldTestManagementWorkflow.php#L55-L91","documentation":"PhutilArgumentUsageException thrown by HeraldTestManagementWorkflow when --type is missing. For the given object the workflow first computes $can_select — adapters where canCreateTestAdapterForObject($object) is true — and the error helpfully lists exactly those content-type keys, so the message doubles as discovery for valid values. A --type is mandatory because one object can be seen by several adapters.","triggerScenarios":"Running 'bin/herald test --object T123' without --type. The strlen() check on getArg('type') fires after adapters are enumerated for the object, and implode(', ', array_keys($can_select)) shows the accepted keys (e.g. 'maniphest.task'). If the listed set is empty, no adapter can create a test for that object at all.","commonSituations":"Users assume the tool infers the content type from the monogram; first-time users don't know the adapter key strings; the follow-up error (content type not valid / can't create adapter) hits those who guess a key like 'task' instead of 'maniphest.task'.","solutions":["Re-run with --type set to one of the keys printed inside the error message itself: bin/herald test --object T123 --type maniphest.task.","Use the fully-qualified adapter key (application.object, e.g. differential.revision, maniphest.task), not a friendly name.","If the message lists no types, the object cannot be dry-run tested — pick a different object or enable the relevant application."],"exampleFix":"# before\nbin/herald test --object T123\n\n# after\nbin/herald test --object T123 --type maniphest.task","handlingStrategy":"validation","validationCode":"// Enumerate selectable types for the object, then require one\n$can_select = array();\nforeach (HeraldAdapter::getAllAdapters() as $key => $adapter) {\n  if ($adapter->canCreateTestAdapterForObject($object)) {\n    $can_select[$key] = $adapter;\n  }\n}\nif (!strlen($args->getArg('type')) || !isset($can_select[$args->getArg('type')])) {\n  // print the valid keys: implode(', ', array_keys($can_select))\n}","typeGuard":"function isSelectableHeraldContentType($object, $type) {\n  foreach (HeraldAdapter::getAllAdapters() as $key => $adapter) {\n    if ($key === $type && $adapter->canCreateTestAdapterForObject($object)) {\n      return true;\n    }\n  }\n  return false;\n}","tryCatchPattern":"try {\n  (new HeraldTestManagementWorkflow())->execute($args);\n} catch (PhutilArgumentUsageException $ex) {\n  // the message itself lists valid content types; re-run with one of them\n}","preventionTips":["Use fully-qualified adapter keys ('maniphest.task', 'differential.revision'), not friendly names.","Parse the valid-type list out of this error when scripting; it is authoritative per object."],"tags":["herald","phabricator","cli","usage-error","missing-argument","adapter","content-type","dry-run"],"backgroundTag":"missing-cli-argument","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}