decentralized-identity/presentation-exchange

Evaluation of first JSONPath match only - intentional or not?

Closed this issue · 2 comments

The current spec says in Section 8:

For each [JSONPath](https://goessner.net/articles/JsonPath/) expression in the path array (incrementing from the 0-index), evaluate the JSONPath expression against the candidate input and repeat the following subsequence on the result.

Repeat until a Field Query Result is found, or the path array elements are exhausted:
    If the result returned no JSONPath match, skip to the next path array element.
    Else, evaluate the first JSONPath match (candidate) as follows:
        If the fields object has no filter, or if candidate validates against the [JSON Schema](https://json-schema.org/specification.html) descriptor specified in filter, then:
        [NOTE](https://identity.foundation/presentation-exchange/#note-8)

        Predicate Feature Only

        If the fields object has a predicate, set Field Query Result to the boolean value resulting from evaluating the Field Query Result against the [JSON Schema](https://json-schema.org/specification.html) descriptor value of the filter property.

        Else
            set Field Query Result to be candidate
        Else, skip to the next path array element.

A JSONPath expression always returns a nodelist i.e., zero or more nodes matching the defined criteria. An example for a path array from the spec:

              "path": [
                "$.credentialSubject.account[*].id",
                "$.vc.credentialSubject.account[*].id",
                "$.account[*].id"
              ],

If I'm reading Section 8 correctly, it says that the expressions in path are evaluated one after the other, but for each expression, only the first result of the nodelist is evaluated ("skip to the next path array element").

This does not seem to be the intended meaning.

Wording adjusted in 50b335d