Subject: [Jsonpath] Re: [Technical Errata Reported] RFC9535 (8343)
From: Carsten Bormann <[email-masked]>
To: "Andrew Newton (andy)" <[email-masked]>
Cc: RFC Errata System <[email-masked]>, [email-masked], [email-masked], Orie Steele <[email-masked]>, [email-masked], Tim Bray <[email-masked]>, [email-masked], [email-masked]
Date: Tue, 25 Mar 2025 18:22:27 +0100
List-Id: Discussion of JSONPath syntax <jsonpath.ietf.org>

On 2025-03-25, at 15:28, Andrew Newton (andy) <[email-masked]> wrote:
> 
> Carsten, are you saying you want to verify the change?

Yes, I have been looking at this in more detail.

The problem is that `literal` matches a prefix of `comparison-expr`, which is an alternative in the lower-priority `logical-expr`, which therefore leads to a truncated parse of `function-argument`.

Moving `logical-expr` first solves that problem.
It also exposes that, in a PEG parser, `logical-expr` actually makes `filter-query` and `function-expr` unreachable via `test-expr`.
This is only a problem for an implementation if the ABNF is used for building a AST and type-checking is tightly bound to the shape of the resulting AST.

(1) One question to Vladimir:

Why did you re-order filter-query and function-expr in the below?

> Original Text
> -------------
> function-argument   = literal /
>                       filter-query / ; (includes singular-query)
>                       logical-expr /
>                       function-expr
> 
> Corrected Text
> --------------
> function-argument   = logical-expr /
>                       function-expr /
>                       filter-query / ; (includes singular-query)
>                       literal

I probably would have proposed:

Feels-more-like-Minimal-Change Text
-----------------------------------
function-argument   = logical-expr /
                      filter-query / ; (includes singular-query)
                      function-expr /
                      literal

(2) An analog change is required in another rule:

comparable          = literal /
                      singular-query / ; singular query value
                      function-expr    ; ValueType

Which needs to be changed to

comparable          = singular-query / ; singular query value
                      function-expr /  ; ValueType
                      literal
                      
(There is currently no text that would prevent registering “true” as a function name in the Function Extensions Subregistry, which would be matched by the `literal` true in `comparable` before getting a chance to be matched in `function-expr`.)

I tested both changes (fail before change, success after change) in the JSONPath tool `jpt`, with these additions to the test input:

$[?foo(1==2)]
$[?true(1)==0]
$[?true(1)==false(0)]

(3)

> PS: also the https://www.rfc-editor.org/rfc/rfc9535#appendix-A is affected

Indeed, any change to the ABNF in the main body needs to be mirrored to the collected ABNF in the Appendix.

Grüße, Carsten