AP24110011695 opened a new issue, #46039:
URL: https://github.com/apache/superset/issues/46039
### Bug description
A user-supplied time-range expression that nests the date functions deeply
crashes `datetime_eval` with an unhandled `RecursionError` (a 500) instead of
arriving as the caller's parse-failure error.
The pyparsing expression grammar in `superset/utils/date_parser.py` recurses
once per nesting level, so the interpreter stack is exhausted before the parser
can report a `ParseException`. `datetime_eval` converts only `ParseException`,
so the `RecursionError` escapes raw — through `get_since_until` →
`get_since_until_from_time_range` — which is reachable from the chart-data
query path (`query_context_processor`) and from user-typed Jinja such as
`get_time_filter(...)`.
Measured on master (Python 3.12, the expression below is ~1.6 KB and
recurses ~4 stack frames per nesting level against the default 1000-frame
limit):
```python
>>> datetime_eval("dateadd(" * 200 + "datetime('2024-01-01')" + ")" * 200)
RecursionError: maximum recursion depth exceeded
```
The threshold sits between 60 and 80 nesting levels (~500 characters), so
the crash needs neither a huge payload nor malicious intent — a duplicated
paste into a freeform time-range field is enough.
### Expected
A malformed expression should surface the same way as every other malformed
expression (a `ValueError` / `TimeRangeParseFailError` at the API layer),
regardless of nesting depth.
### Actual
`RecursionError` propagates unhandled and the request fails as a 500.
### Suggested fix
Catch `RecursionError` in `datetime_eval` next to the existing
`ParseException` boundary and re-raise as a `ValueError`. I have this ready
with a regression test and will open a PR shortly.
### Additional context
Same family as #45260 (unhandled library exception at the `datetime_eval`
boundary → 500) and #45269 (a 500 from `get_time_filter`), both fixed or in
flight.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]