{"record":{"id":"7cb8989410398f97","repo":"phacility/phabricator","slug":"specify-a-content-type-to-run-rules-for-the-speci","errorCode":null,"errorMessage":"Specify a content type to run rules for. The specified content type (\"%s\") is not valid. For this object, valid content types are: %s.","messagePattern":"Specify a content type to run rules for\\. The specified content type \\(\"(.+?)\"\\) is not valid\\. For this object, valid content types are: (.+?)\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/herald/management/HeraldTestManagementWorkflow.php","lineNumber":82,"sourceCode":"\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(\n            'The specified content type (\"%s\") does not support dry runs. '.\n            'Choose a testable content type. For this object, valid content '.\n            'types are: %s.',\n            $content_type,\n            implode(', ', array_keys($can_select))));\n      }\n    }\n\n    $adapter = $can_select[$content_type]->newTestAdapter(","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/herald/management/HeraldTestManagementWorkflow.php#L64-L100","documentation":"Usage error thrown by 'bin/herald test --object <object> --type <type>'. The workflow builds $can_select from Herald adapters that both apply to the object (isTestAdapterForObject) and support dry runs (canCreateTestAdapterForObject). The given --type matched no adapter key at all -- it is not even in $display_adapters -- so it can never be tested, and the message lists every valid key.","triggerScenarios":"Running 'bin/herald test --object T123 --type taks' (typo), or passing a value that is not a Herald adapter content-type key (e.g. --type wiki when no such adapter exists for the object). Matching is exact and case-sensitive against adapter keys like TASK, DREV, CMIT.","commonSituations":"Typos in --type; scripts written against a different Phabricator version where adapter keys differ; testing an object whose applicable adapters are all display-only; assuming the flag is case-insensitive.","solutions":["Re-run with one of the content types listed verbatim in the error message, e.g. 'bin/herald test --object T123 --type TASK'.","Run 'bin/herald test --object <object>' with no --type to have the command print the valid content type list.","Verify the --object monogram resolves to the object kind you expect; the selectable adapter set is derived from it.","If you are scripting this, resolve the key from HeraldAdapter::getAllAdapters() instead of hardcoding it."],"exampleFix":"// before\n./bin/herald test --object T123 --type taks\n// after\n./bin/herald test --object T123 --type TASK","handlingStrategy":"validation","validationCode":"// Before invoking bin/herald test, confirm the type is selectable for the object:\n$adapters = HeraldAdapter::getAllAdapters();\n$can_select = array();\nforeach ($adapters as $key => $adapter) {\n  if (!$adapter->isTestAdapterForObject($object)) { continue; }\n  if (!$adapter->isAvailableToUser($viewer)) { continue; }\n  if ($adapter->canCreateTestAdapterForObject($object)) {\n    $can_select[$key] = $adapter;\n  }\n}\nif (!isset($can_select[$type])) {\n  throw new InvalidArgumentException(\n    'Invalid --type; valid: '.implode(', ', array_keys($can_select)));\n}","typeGuard":"function isSelectableHeraldContentType($object, $viewer, $type) {\n  $adapters = HeraldAdapter::getAllAdapters();\n  return isset($adapters[$type])\n    && $adapters[$type]->isTestAdapterForObject($object)\n    && $adapters[$type]->isAvailableToUser($viewer)\n    && $adapters[$type]->canCreateTestAdapterForObject($object);\n}","tryCatchPattern":null,"preventionTips":["Always copy the content type from the list the error prints rather than retyping it.","In scripts, derive --type from HeraldAdapter::getAllAdapters() instead of hardcoding.","Treat a mismatched type as a build-time check: fail the script before shelling out to bin/herald."],"tags":["herald","phabricator","cli","argument-validation","dry-run"],"backgroundTag":"invalid-argument-value","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}