fix: catch correct exception when parsing filter (#15458)

This commit is contained in:
Peter Braun
2024-08-22 16:12:54 +02:00
committed by GitHub
parent 1b5cdf6bef
commit c6223c076f

View File

@@ -1,5 +1,7 @@
import re import re
from functools import reduce from functools import reduce
from django.core.exceptions import FieldDoesNotExist
from pyparsing import ( from pyparsing import (
infixNotation, infixNotation,
opAssoc, opAssoc,
@@ -353,7 +355,7 @@ class SmartFilter(object):
try: try:
res = boolExpr.parseString('(' + filter_string + ')') res = boolExpr.parseString('(' + filter_string + ')')
except ParseException: except (ParseException, FieldDoesNotExist):
raise RuntimeError(u"Invalid query %s" % filter_string_raw) raise RuntimeError(u"Invalid query %s" % filter_string_raw)
if len(res) > 0: if len(res) > 0: