jurismarches / luqum

A lucene query parser generating ElasticSearch queries and more !
Other
187 stars 42 forks source link

Parser fails with 'TypeError' on invalid query "~]" #69

Closed ygavenchuk closed 2 years ago

ygavenchuk commented 3 years ago

There's a query from pair of symbols which breaks the error handling of the parser, so we can't get relevant information about the syntax error.

How to reproduce:

from luqum.parser import parser

parser.parse('~]')

Expected result: ParseSyntaxError Actual result: TypeError: __str__ returned non-string (type NoneType)

Possible fix:

Update the TokenValue.__str__ method to always return string. I.e.

class TokenValue:
# ...
    def __str__(self):
        return str(self.value)
alexgarel commented 3 years ago

Hello @ygavenchuk, that's a good idea.

ygavenchuk commented 3 years ago

No problem

delkopiso commented 2 years ago

@alexgarel could you review https://github.com/jurismarches/luqum/pull/74?

delkopiso commented 2 years ago

@alexgarel will you be publishing a patch release for this fix?