Valid $or Pattern fails RuleCompiler check
- Dominant language
- Java
- Stars
- 615
- Forks
- 82
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 7
Description
## Describe the bug
When using the `RuleCompiler::check` function to validate a rule pattern, I am receiving the following issue despite the pattern being valid:
Input:
```
{
"$or": [{
"title": [{
"anything-but": ["Test"]
}]
}, {
"severity": [{
"numeric": ["=", 5]
}]
}]
}
```
Error message:
```
Unrecognized match type title at [Source: (String)"{ "$or": [{ "title": [{ "anything-but": ["Test"] }] }, { "severity": [{ "numeric": ["=", 5] }] }] }"; line: 3, column: 19]
```
Here "title" and "severity" are property keys of our JSON document and not reserved keywords but it seems to be hitting the validation logic at https://github.com/aws/event-ruler/blob/v1.8.1/src/main/software/amazon/event/ruler/RuleCompiler.java#L422 and failing.
## To Reproduce
Invoke the `check()` function with the above payload
## Expected behavior
`check()` function should return null as pattern is valid
## Environment:
Java Version: JDK21
Ruler Package: 1.8.1
## Additional context
We are internal SDO team
Contributor guide
Research direction
Start in src/main/software/amazon/event/ruler/RuleCompiler.java around the validation logic referenced at line 422, and reproduce the issue by calling check() with the supplied $or pattern. Confirm that the valid property keys title and severity are accepted and that check() returns null, then add or update a regression test for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100