FrancescoCastaldi commented on code in PR #45822:
URL: https://github.com/apache/superset/pull/45822#discussion_r4422120978
##########
superset/models/helpers.py:
##########
@@ -6980,11 +7013,27 @@ def get_sqla_query( # pylint:
disable=too-many-arguments,too-many-locals,too-ma
and isinstance(eq, str)
and col_obj is not None
):
- _since, _until = get_since_until_from_time_range(
- time_range=eq,
- time_shift=time_shift,
- extras=extras,
- )
+ try:
+ _since, _until = get_since_until_from_time_range(
+ time_range=eq,
+ time_shift=time_shift,
+ extras=extras,
+ )
+ except (
+ TimeRangeParseFailError,
+ TimeRangeAmbiguousError,
+ ValidationError,
+ ValueError,
Review Comment:
In commit `089c8d37a4`, we addressed this by adding `TypeError` to the
caught exception tuple across all three `get_since_until_from_time_range` call
sites in `superset/models/helpers.py` (lines 3089, 3227, and 7027). When mixed
offset-naive and offset-aware datetimes like `"2024-01-01T00:00:00Z :
2024-01-02"` are passed, `get_since_until` raises a `TypeError` during
timestamp comparison (`_since > _until`). This is now properly intercepted and
converted into a `QueryObjectValidationError`, consistently returning 400
instead of 500.
Additionally, we formatted the exception statement in
`superset/models/helpers.py` to satisfy `ruff-format` (resolving the
`pre-commit (current)` CI failure) and added a dedicated regression unit test
in `tests/unit_tests/models/helpers_test.py` verifying mixed-timezone temporal
ranges.
--
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]