You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The root cause for the issue is that a filter [?…]bracket-specifier ends a projection, whereas a flatten []bracket-specifier does not. I’m not sure where does this requirement come from.
Here are the two expressions:
Expression 1: [?stack==''].branch[?starts_with(@, 'one')] (this incorrectly raises an invalid-type error). Edit this turns out to be the correct result by design. But this is very counter-intuitive and should probably be fixed by a proposal in the spec.
By contrast, JmesPath.Netdoes not have the bug returns a result. The reason is that JmesPath.NET uses a Lex-Yacc based parser syntax that is different than the Pratt-based parser used in most other implementations. The behaviour (intuitive, but incorrect) is due to the initial lack of deep knowledge for how bracket-specifier were designed.
Activity
springcomp commentedon May 15, 2025
The root cause for the issue is that a filter
[?…]bracket-specifierends a projection, whereas a flatten[]bracket-specifierdoes not. I’m not sure where does this requirement come from.Here are the two expressions:
[?stack==''].branch[?starts_with(@, 'one')](thisincorrectlyraises aninvalid-typeerror). Edit this turns out to be the correct result by design. But this is very counter-intuitive and should probably be fixed by a proposal in the spec.[].branch[?starts_with(@, 'one')]this returns[ [ "one/" ], [] ]Expression 1 AST
[?stack==''].branch[?starts_with(@, 'one')]JSON representation of the AST
{ "type": "filter_projection", "children": [ { "type": "filter_projection", "children": [ { "type": "identity", "children": [] }, { "type": "field", "children": [], "value": "branch" }, { "type": "comparator", "children": [ { "type": "field", "children": [], "value": "stack" }, { "type": "literal", "value": "", "children": [] } ], "value": "eq" } ] }, { "type": "identity", "children": [] }, { "type": "function_expression", "children": [ { "type": "current", "children": [] }, { "type": "literal", "value": "one", "children": [] } ], "value": "starts_with" } ] }Expression 2 AST
[].branch[?starts_with(@, 'one')]this returns[ [ "one/" ], [] ]JSON representation of the AST
{ "type": "projection", "children": [ { "type": "flatten", "children": [ { "type": "identity", "children": [] } ] }, { "type": "filter_projection", "children": [ { "type": "field", "children": [], "value": "branch" }, { "type": "identity", "children": [] }, { "type": "function_expression", "children": [ { "type": "current", "children": [] }, { "type": "literal", "value": "one", "children": [] } ], "value": "starts_with" } ] } ] }springcomp commentedon May 22, 2025
By contrast, JmesPath.Net
does not have the bugreturns a result. The reason is that JmesPath.NET uses a Lex-Yacc based parser syntax that is different than the Pratt-based parser used in most other implementations. The behaviour (intuitive, but incorrect) is due to the initial lack of deep knowledge for howbracket-specifierwere designed.There, the ASTs looks like this:
Expression 1 AST
[?stack==''].branch[?starts_with(@, 'one')]Expression 2 AST
[].branch[?starts_with(@, 'one')]