{"record":{"id":"2dd4075f947be7c1","repo":"phacility/phabricator","slug":"expected-condition-value-to-be-an-array","errorCode":null,"errorMessage":"Expected condition value to be an array.","messagePattern":"Expected condition value to be an array\\.","errorType":"validation","errorClass":"HeraldInvalidConditionException","httpStatus":null,"severity":"error","filePath":"src/applications/herald/adapter/HeraldAdapter.php","lineNumber":495,"sourceCode":"          throw new HeraldInvalidConditionException(\n            pht('Expected condition value to be an array.'));\n        }\n        $condition_value = array_fuse($condition_value);\n        return isset($condition_value[$field_value]);\n      case self::CONDITION_IS_NOT_ANY:\n        if (!is_array($condition_value)) {\n          throw new HeraldInvalidConditionException(\n            pht('Expected condition value to be an array.'));\n        }\n        $condition_value = array_fuse($condition_value);\n        return !isset($condition_value[$field_value]);\n      case self::CONDITION_INCLUDE_ALL:\n        if (!is_array($field_value)) {\n          throw new HeraldInvalidConditionException(\n            pht('Object produced non-array value!'));\n        }\n        if (!is_array($condition_value)) {\n          throw new HeraldInvalidConditionException(\n            pht('Expected condition value to be an array.'));\n        }\n\n        $have = array_select_keys(array_fuse($field_value), $condition_value);\n        return (count($have) == count($condition_value));\n      case self::CONDITION_INCLUDE_ANY:\n        return (bool)array_select_keys(\n          array_fuse($field_value),\n          $condition_value);\n      case self::CONDITION_INCLUDE_NONE:\n        return !array_select_keys(\n          array_fuse($field_value),\n          $condition_value);\n      case self::CONDITION_EXISTS:\n      case self::CONDITION_IS_TRUE:\n        return (bool)$field_value;\n      case self::CONDITION_NOT_EXISTS:\n      case self::CONDITION_IS_FALSE:","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/herald/adapter/HeraldAdapter.php#L477-L513","documentation":"While evaluating a Herald rule, the CONDITION_INCLUDE_ALL branch ('include all of') requires both the field value (checked first, 'Object produced non-array value!') and the stored condition value to be arrays. Here the field produced an array but the condition's saved value is a scalar, so the adapter throws HeraldInvalidConditionException. The Herald engine catches it, marks the rule as errored in the transcript, and the rule does not apply.","triggerScenarios":"A rule with an 'include all of' condition (e.g. 'include all of these projects/reviewers') whose stored value is a plain string/PHID instead of a list — typically written via the Conduit API, a rule import, or corrupted storage rather than the web editor (the UI saves arrays and willSaveCondition validates).","commonSituations":"Rules created or edited via herald.rule.edit Conduit with value passed as a scalar; migrations between instances; batch rule generation scripts that did not wrap values in an array.","solutions":["Re-save the rule in the Herald web UI: open the rule, the condition editor will normalize the value into a list, then save.","If editing via API, pass the value as an array, e.g. array('PHID-PROJ-...') instead of 'PHID-PROJ-...'.","For many broken rules, fix the herald_condition.value column (or re-save each rule) so the value is a JSON/PHP array."],"exampleFix":"// before (herald.rule.edit via Conduit)\n{\"value\": \"PHID-PROJ-aaaa\"}\n\n// after\n{\"value\": [\"PHID-PROJ-aaaa\"]}","handlingStrategy":"validation","validationCode":"// When writing rules via API, pre-validate multi-value conditions:\n$multi = array(\n  HeraldAdapter::CONDITION_INCLUDE_ALL,\n  HeraldAdapter::CONDITION_IS_ANY,\n  HeraldAdapter::CONDITION_IS_NOT_ANY,\n);\nif (in_array($condition_type, $multi, true) && !is_array($value)) {\n  $value = array($value); // normalize to the array shape the adapter requires\n}","typeGuard":"function isHeraldMultiValueCondition($type) {\n  return in_array($type, array(\n    HeraldAdapter::CONDITION_INCLUDE_ALL,\n    HeraldAdapter::CONDITION_IS_ANY,\n    HeraldAdapter::CONDITION_IS_NOT_ANY,\n  ), true);\n}","tryCatchPattern":"try {\n  $adapter->doesConditionMatch($rule, $condition, $field_value);\n} catch (HeraldInvalidConditionException $ex) {\n  // engine-level handling: rule is skipped and marked errored;\n  // in custom scripts, log the rule monogram and skip the rule\n}","preventionTips":["Prefer the Herald web editor, which saves values in the correct shape.","When using herald.rule.edit, always wrap IS_ANY/NOT_ANY/INCLUDE_ALL values in arrays.","Check the Herald transcript for errored rules after migrations or bulk edits."],"tags":["herald","condition","phabricator"],"backgroundTag":"rule-condition-validation-failed","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}