jmespath.js icon indicating copy to clipboard operation
jmespath.js copied to clipboard

jmespath.js parser error showing undefined instead of actual token type and value

Open David-Yuen opened this issue 1 year ago • 1 comments

When the jmespath parser handles a syntax error related to parsing slice expressions, it's throwing an error message:

Syntax error: unexpected token: undefined(undefined)

Which, it should actually have token and value instead of undefined.

In the Parser's _parseSliceExpression() function, it looks like this:

                  var t = this._lookahead(0);
                  var error = new Error("Syntax error, unexpected token: " +
                                        t.value + "(" + t.type + ")");

Solution: it should use this._lookaheadToken() instead of this._lookahead(). The this._lookaheadToken() will return a token object that will actually contain .type and .value properties

David-Yuen avatar Feb 29 '24 16:02 David-Yuen

@David-Yuen you may want to use the JMESPath Community fork of this library. While being fully standards compliant, it includes many improvements and bug fixes.

That particular issue is included in the community port of this library.

springcomp avatar Oct 27 '24 09:10 springcomp