Treat dotted routing keys as concrete boolean bindings

Allow BooleanConstraintEvaluator to substitute simple routing-key bindings like order.pay while avoiding accidental substitution of variable names.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-13 21:36:47 +02:00
parent c1085a2bd3
commit 69361e5a60

View File

@@ -59,6 +59,7 @@ public final class BooleanConstraintEvaluator {
try { try {
return parseExpression(expression.replaceAll("\\s+", "")); return parseExpression(expression.replaceAll("\\s+", ""));
} catch (Exception e) { } catch (Exception e) {
// Be conservative in pruning: if we can't parse the expression, do not discard paths.
return !expression.contains("false"); return !expression.contains("false");
} }
} }
@@ -108,6 +109,12 @@ public final class BooleanConstraintEvaluator {
if (boundValue.contains(".") && Character.isUpperCase(boundValue.charAt(boundValue.lastIndexOf('.') + 1))) { if (boundValue.contains(".") && Character.isUpperCase(boundValue.charAt(boundValue.lastIndexOf('.') + 1))) {
return true; return true;
} }
// Treat simple routing keys (e.g. order.pay) as concrete string bindings, but avoid
// mistaking variable names (e.g. machineType) for concrete values.
if ((boundValue.contains(".") || boundValue.contains("/") || boundValue.contains("-"))
&& boundValue.matches("^[a-zA-Z0-9._/-]+$")) {
return true;
}
return boundValue.equals(boundValue.toUpperCase(Locale.ROOT)) && boundValue.chars().allMatch(ch -> return boundValue.equals(boundValue.toUpperCase(Locale.ROOT)) && boundValue.chars().allMatch(ch ->
Character.isUpperCase(ch) || ch == '_'); Character.isUpperCase(ch) || ch == '_');
} }