phacility/phabricator · error · HeraldInvalidConditionException
The second regexp in the regexp pair, "%s", is not a valid r
Error message
The second regexp in the regexp pair, "%s", is not a valid regexp.
What it means
Thrown by HeraldAdapter::willSaveCondition() for CONDITION_REGEXP_PAIR after the JSON array decoded correctly, had exactly two elements, and the first (key) regexp passed validation. The second element is shifted off as the value regexp and smoke-tested with @preg_match($val_regexp, ''); a boolean false return raises this error, naming the second (value) regexp specifically.
Source
Thrown at src/applications/herald/adapter/HeraldAdapter.php:664
'elements.',
$condition_value));
}
$key_regexp = array_shift($json);
$val_regexp = array_shift($json);
$key_ok = @preg_match($key_regexp, '');
if ($key_ok === false) {
throw new HeraldInvalidConditionException(
pht(
'The first regexp in the regexp pair, "%s", is not a valid '.
'regexp.',
$key_regexp));
}
$val_ok = @preg_match($val_regexp, '');
if ($val_ok === false) {
throw new HeraldInvalidConditionException(
pht(
'The second regexp in the regexp pair, "%s", is not a valid '.
'regexp.',
$val_regexp));
}
break;
case self::CONDITION_CONTAINS:
case self::CONDITION_NOT_CONTAINS:
case self::CONDITION_IS:
case self::CONDITION_IS_NOT:
case self::CONDITION_IS_ANY:
case self::CONDITION_IS_NOT_ANY:
case self::CONDITION_INCLUDE_ALL:
case self::CONDITION_INCLUDE_ANY:
case self::CONDITION_INCLUDE_NONE:
case self::CONDITION_IS_ME:
case self::CONDITION_IS_NOT_ME:
case self::CONDITION_RULE:View on GitHub (pinned to 5720a38cfe)
Solutions
- Fix the SECOND element of the JSON array to be a valid delimited PCRE pattern, e.g. "@urgent@".
- Re-test the whole pair rather than one element, since both are validated independently.
- Escape delimiter characters inside the pattern or choose a different delimiter.
Example fix
// before ["@^title$@", "urgent|asap"] // after ["@^title$@", "@(urgent|asap)@"]
Defensive patterns
Strategy: validation
Validate before calling
list($key_re, $val_re) = phutil_json_decode($value);
if (@preg_match($val_re, '') === false) {
return pht('Second regexp of the pair is invalid; add delimiters.');
} Type guard
function isValidRegexpPairValue($pair_json) {
$json = phutil_json_decode($pair_json);
return @preg_match($json[1], '') !== false;
} Try / catch
try {
$editor->save();
} catch (HeraldInvalidConditionException $ex) {
// 'second regexp ... is not valid' -> only element 1 needs fixing
} Prevention
- After fixing the first element of a pair, immediately re-test the second — the two checks run sequentially.
- Write pairs in a builder that formats both regexes through the same delimiter-adding helper.
When it happens
Trigger: Saving a regexp pair like ["@^title$@", "urgent.*"] where only the SECOND element is a broken PCRE pattern (no delimiters, unbalanced delimiter, invalid modifier, syntax error). If you get this after error 823, you already fixed the key and now only the value pattern is still wrong.
Common situations: Fixing the first regexp after a pair-validation failure but leaving the second one unedited; or building pairs programmatically where only the value slot receives unformatted user input.
Related errors
- The regular expression "%s" is not valid. Regular expression
- The first regexp in the regexp pair, "%s", is not a valid re
- The regular expression pair "%s" is not valid JSON. Enter a
- The regular expression pair "%s" must have exactly two eleme
- Unknown condition "%s"!
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/193b495d8672413f.
Report an issue: GitHub.