phacility/phabricator · error · HeraldInvalidConditionException
Unknown condition '%s'.
Error message
Unknown condition '%s'.
What it means
doesConditionMatch() switches over the known CONDITION_* constants; any condition whose stored field-condition constant matches no case falls through to default and throws HeraldInvalidConditionException("Unknown condition '%s'."). The stored constant is not one this adapter/engine version recognizes.
Source
Thrown at src/applications/herald/adapter/HeraldAdapter.php:608
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));
}
}
public function willSaveCondition(HeraldCondition $condition) {
$condition_type = $condition->getFieldCondition();
$condition_value = $condition->getValue();
switch ($condition_type) {
case self::CONDITION_REGEXP:
case self::CONDITION_NOT_REGEXP:
$ok = @preg_match($condition_value, '');
if ($ok === false) {
throw new HeraldInvalidConditionException(
pht(
'The regular expression "%s" is not valid. Regular expressions '.
'must have enclosing characters (e.g. "@/path/to/file@", not '.
'"/path/to/file") and be syntactically correct.',View on GitHub (pinned to 5720a38cfe)
Solutions
- Inspect the rule's conditions in the Herald UI and re-save the rule to normalize them, or delete the broken condition.
- If an extension's condition is involved, reinstall/enable the extension or remove the condition that uses it.
- Find the offending row (herald_condition, fieldName/fieldCondition) and correct or delete it, then re-evaluate the rule.
Defensive patterns
Strategy: validation
Validate before calling
// Validate stored condition constants against the adapter's known set:
$valid = $adapter->getConditionConstants(); // known CONDITION_* values
if (!in_array($condition->getFieldCondition(), $valid, true)) {
// unknown constant - fix or delete the condition row
} Prevention
- Never hand-edit herald_condition constants; use the UI.
- Before uninstalling an extension that adds Herald conditions, remove rules using them.
When it happens
Trigger: A herald_condition row stores an arbitrary/unknown condition constant — hand-edited data, a condition defined by an extension that is no longer installed, or a database moved between Phabricator versions with different condition sets.
Common situations: Disabling/uninstalling an application or extension that contributed custom Herald conditions while rules still use them; manual DB edits; partial or failed upgrades leaving rows in an inconsistent state.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
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/c535f7239a54f628.
Report an issue: GitHub.