[Jsonpath] Re: [Technical Errata Reported] RFC9535 (8343)

Carsten Bormann <cabo@tzi.org> Tue, 25 March 2025 17:22 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: jsonpath@mail2.ietf.org
Delivered-To: jsonpath@mail2.ietf.org
Received: from localhost (localhost [127.0.0.1]) by mail2.ietf.org (Postfix) with ESMTP id E56DE1239DDF for <jsonpath@mail2.ietf.org>; Tue, 25 Mar 2025 10:22:31 -0700 (PDT)
X-Virus-Scanned: amavisd-new at ietf.org
X-Spam-Flag: NO
X-Spam-Score: -4.189
X-Spam-Level:
X-Spam-Status: No, score=-4.189 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, T_SPF_PERMERROR=0.01] autolearn=ham autolearn_force=no
Received: from mail2.ietf.org ([166.84.6.31]) by localhost (mail2.ietf.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uMmZBx9U6gP4 for <jsonpath@mail2.ietf.org>; Tue, 25 Mar 2025 10:22:30 -0700 (PDT)
Received: from smtp.zfn.uni-bremen.de (smtp.zfn.uni-bremen.de [IPv6:2001:638:708:32::21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail2.ietf.org (Postfix) with ESMTPS id E34261239DD9 for <jsonpath@ietf.org>; Tue, 25 Mar 2025 10:22:29 -0700 (PDT)
Received: from [192.168.217.145] (p548dc3ec.dip0.t-ipconnect.de [84.141.195.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4ZMcDg6Zg1zDChn; Tue, 25 Mar 2025 18:22:27 +0100 (CET)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <f87965d1-c1db-4c5a-a0c6-f5f9d61de921@hxr.us>
Date: Tue, 25 Mar 2025 18:22:27 +0100
X-Mao-Original-Outgoing-Id: 764616147.331422-f3e7851a292949740fb8c18757d38947
Content-Transfer-Encoding: quoted-printable
Message-Id: <EBFD5D95-629B-4151-AEFF-A8651A0937A1@tzi.org>
References: <20250324144730.970D2210673@rfcpa.rfc-editor.org> <F5AABC54-3B2A-4621-A77E-07CC24B87642@tzi.org> <f87965d1-c1db-4c5a-a0c6-f5f9d61de921@hxr.us>
To: "Andrew Newton (andy)" <andy@hxr.us>
X-Mailer: Apple Mail (2.3608.120.23.2.7)
Message-ID-Hash: 227C546M5QIAHOJR7FSJZRXIVEYVKQEK
X-Message-ID-Hash: 227C546M5QIAHOJR7FSJZRXIVEYVKQEK
X-MailFrom: cabo@tzi.org
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
CC: RFC Errata System <rfc-editor@rfc-editor.org>, stefan.goessner@fh-dortmund.de, glyn.normington@gmail.com, Orie Steele <orie@transmute.industries>, james.ietf@gmail.com, Tim Bray <tbray@textuality.com>, vladimir.gorej@gmail.com, jsonpath@ietf.org
X-Mailman-Version: 3.3.9rc6
Precedence: list
Subject: [Jsonpath] Re: [Technical Errata Reported] RFC9535 (8343)
List-Id: Discussion of JSONPath syntax <jsonpath.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/jsonpath/iMGJ8AaLLPfnC-YyuQ1flDKF2k0>
List-Archive: <https://mailarchive.ietf.org/arch/browse/jsonpath>
List-Help: <mailto:jsonpath-request@ietf.org?subject=help>
List-Owner: <mailto:jsonpath-owner@ietf.org>
List-Post: <mailto:jsonpath@ietf.org>
List-Subscribe: <mailto:jsonpath-join@ietf.org>
List-Unsubscribe: <mailto:jsonpath-leave@ietf.org>

On 2025-03-25, at 15:28, Andrew Newton (andy) <andy@hxr.us> 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