Defer unescaping in Parser until tokens are used as values#1244
Merged
brharrington merged 1 commit intoJun 12, 2026
Conversation
The query/data expression parser unescaped each comma-separated token up front, before deciding whether it was a structural token (a parenthesis or a `:operator`). As a result an escaped special character that was intended as data, such as `(` or `:in`, was unescaped to `(` or `:in` and then mistaken for syntax. Depending on the expression this either threw `invalid query expression` (a lone escaped paren or a top-level escaped operator) or produced a structurally different query. In a streaming context a subscription whose expression fails to parse silently matches nothing, so streaming results could diverge from the backend. Match structural tokens against the raw token and only unescape when a token is stored as a value (the scalar push and list members). This mirrors the Atlas server parser (Interpreter.nextStep / popAndPushList). Also align escaping with the server so values round-trip: escape `:` in addition to comma and whitespace, and escape a standalone `(`/`)` token. Add a fast path to unescape to avoid allocating when there is nothing to do.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The query/data expression parser unescaped each comma-separated token up front, before deciding whether it was a structural token (a parenthesis or a
:operator). As a result an escaped special character that was intended as data, such as(or:in, was unescaped to(or:inand then mistaken for syntax. Depending on the expression this either threwinvalid query expression(a lone escaped paren or a top-level escaped operator) or produced a structurally different query. In a streaming context a subscription whose expression fails to parse silently matches nothing, so streaming results could diverge from the backend.Match structural tokens against the raw token and only unescape when a token is stored as a value (the scalar push and list members). This mirrors the Atlas server parser (Interpreter.nextStep / popAndPushList).
Also align escaping with the server so values round-trip: escape
:in addition to comma and whitespace, and escape a standalone(/)token. Add a fast path to unescape to avoid allocating when there is nothing to do.