phacility/phabricator · error · HeraldInvalidConditionException
Condition references a rule which does not exist!
Error message
Condition references a rule which does not exist!
What it means
For CONDITION_RULE / CONDITION_NOT_RULE ('linked/other rule' conditions), the condition value is the PHID of another Herald rule; the adapter looks it up with $engine->getRule($condition_value). A null result — the referenced rule does not exist or was not loaded into the engine — throws HeraldInvalidConditionException. Most commonly the referenced rule was deleted while this rule still points at it.
Source
Thrown at src/applications/herald/adapter/HeraldAdapter.php:593
pht('First regular expression is invalid!'));
}
if ($key_matches) {
$value_matches = @preg_match($value_regexp, $value);
if ($value_matches === false) {
throw new HeraldInvalidConditionException(
pht('Second regular expression is invalid!'));
}
if ($value_matches) {
return true;
}
}
}
return false;
case self::CONDITION_RULE:
case self::CONDITION_NOT_RULE:
$rule = $engine->getRule($condition_value);
if (!$rule) {
throw new HeraldInvalidConditionException(
pht('Condition references a rule which does not exist!'));
}
$is_not = ($condition_type == self::CONDITION_NOT_RULE);
$result = $engine->doesRuleMatch($rule, $this);
if ($is_not) {
$result = !$result;
}
return $result;
case self::CONDITION_HAS_BIT:
return (($condition_value & $field_value) === (int)$condition_value);
case self::CONDITION_NOT_BIT:
return (($condition_value & $field_value) !== (int)$condition_value);
default:
throw new HeraldInvalidConditionException(
pht("Unknown condition '%s'.", $condition_type));
}
}View on GitHub (pinned to 5720a38cfe)
Solutions
- Edit the rule and remove or re-point the 'references rule' condition to an existing rule.
- If you must delete a rule, first check whether other rules' conditions reference its PHID.
- For bulk hygiene, query herald_condition for values equal to deleted rule PHIDs and clean them up.
Defensive patterns
Strategy: validation
Validate before calling
// Before saving a rule that references another rule:
$ref = id(new HeraldRuleQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withPHIDs(array($referenced_rule_phid))
->executeOne();
if (!$ref) {
// do not save the condition - the referenced rule does not exist
} Prevention
- Before deleting a Herald rule, search other rules for conditions referencing its PHID.
- After imports/migrations, verify rule-reference conditions still resolve.
When it happens
Trigger: Rule A has a 'rule' condition referencing rule B (by PHID); rule B is deleted or disabled beyond engine visibility; next evaluation of rule A fails with this exception and A stops applying.
Common situations: Deleting rules that are still referenced by other rules; moving a rule's content into a new rule and deleting the old one; migrations where referenced PHIDs do not exist in the target instance.
Related errors
- Expected condition value to be an array.
- Regular expression "%s" in Herald rule "%s" is not valid, or
- Regular expression pair is not valid JSON!
- Regular expression pair is not a pair!
- First regular expression is invalid!
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/e5cbcafc7e342664.
Report an issue: GitHub.