Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JSONSelection] Fix precedence of parsing NamedPathSelection within NamedSelection rule #5156

Merged
merged 3 commits into from
May 13, 2024

Conversation

benjamn
Copy link
Member

@benjamn benjamn commented May 13, 2024

Thanks to @lennyburdette's playground, I quickly found a bug with the parsing of NamedPathSelection. This PR adds a number of regression tests and fixes the bug.

I updated the README.md to emphasize the importance of parsing NamedPathSelection before NamedFieldSelection and NamedQuotedSelection, so just read those changes if you're curious why this solution makes sense for a parser like this one.

@router-perf
Copy link

router-perf bot commented May 13, 2024

CI performance tests

  • step - Basic stress test that steps up the number of users over time
  • events_big_cap_high_rate_callback - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity using callback mode
  • large-request - Stress test with a 1 MB request payload
  • events - Stress test for events with a lot of users and deduplication ENABLED
  • xxlarge-request - Stress test with 100 MB request payload
  • events_without_dedup - Stress test for events with a lot of users and deduplication DISABLED
  • xlarge-request - Stress test with 10 MB request payload
  • step-jemalloc-tuning - Clone of the basic stress test for jemalloc tuning
  • events_callback - Stress test for events with a lot of users and deduplication ENABLED in callback mode
  • no-graphos - Basic stress test, no GraphOS.
  • reload - Reload test over a long period of time at a constant rate of users
  • events_big_cap_high_rate - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity
  • events_without_dedup_callback - Stress test for events with a lot of users and deduplication DISABLED using callback mode
  • const - Basic stress test that runs with a constant number of users

Comment on lines 67 to 81
impl NamedSelection {
fn parse(input: &str) -> IResult<&str, Self> {
alt((
// We must try parsing NamedPathSelection before NamedFieldSelection
// and NamedQuotedSelection because a NamedPathSelection without a
// leading `.`, such as `alias: some.nested.path` has a prefix that
// can be parsed as a NamedFieldSelection: `alias: some`. Parsing
// then fails when it finds the remaining `.nested.path` text. Some
// parsers would solve this by forbidding `.` in the "lookahead" for
// Named{Field,Quoted}Selection, but negative lookahead is tricky in
// nom, so instead we greedily parse NamedPathSelection first.
Self::parse_path,
Self::parse_field,
Self::parse_quoted,
Self::parse_path,
Self::parse_group,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the operative change that fixes the NamedPathSelection parsing ambiguity.

@benjamn benjamn changed the title Benjamn/fix named path selection precedence [JSONSelection] Fix precedence of parsing NamedPathSelection within NamedSelection rule May 13, 2024
@benjamn benjamn changed the title [JSONSelection] Fix precedence of parsing NamedPathSelection within NamedSelection rule [JSONSelection] Fix precedence of parsing NamedPathSelection within NamedSelection rule May 13, 2024
@benjamn benjamn merged commit 5daa04a into connectors May 13, 2024
10 of 13 checks passed
@benjamn benjamn deleted the benjamn/fix-NamedPathSelection-precedence branch May 13, 2024 19:00
benjamn added a commit that referenced this pull request Jul 31, 2024
This is a follow-up to PR #5156, which reordered some rules in the
JSONSelection grammar but neglected to regenerate the SVG diagrams.
benjamn added a commit that referenced this pull request Aug 1, 2024
This is a follow-up to PR #5156, which reordered some rules in the
JSONSelection grammar but neglected to regenerate the SVG diagrams.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants