jmespath/jmespath.js

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

Opened this issue · 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 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.