bodapatisaikrishna opened a new pull request, #44211:
URL: https://github.com/apache/superset/pull/44211

   ### SUMMARY
   
   `get_since_until()` recognizes the documented `time_range` presets ("Last 
day",
   "Next 5 months", "Current week", "previous calendar month", ...) with a set 
of
   `time_range.startswith("Last")`-style checks. Every one of these checks is
   case-sensitive against a single hardcoded literal, even though every regex
   pattern later in the same function matches with `re.IGNORECASE`.
   
   A `time_range` that doesn't match one of these prefixes (and has no `" : "`
   separator) falls through to the function's final branch, which uses the
   separate `since`/`until` keyword arguments instead — both empty in this call
   shape — and returns `(None, today)` with no error. So a preset that differs
   from the function's hardcoded casing doesn't raise or get corrected, it just
   silently loses its lower bound:
   
   ```python
   >>> from superset.utils.date_parser import get_since_until
   >>> get_since_until(time_range="Last week")   # matches the "Last" prefix
   (datetime.datetime(2026, 9, 6, 0, 0), datetime.datetime(2026, 9, 13, 0, 0))
   >>> get_since_until(time_range="last week")   # only the casing differs
   (None, datetime.datetime(2026, 9, 13, 0, 0))
   ```
   
   That's the difference between "chart data from the last 7 days" and "chart
   data from the beginning of time to today" for a chart/dashboard whose saved
   time range happens to be cased differently than these literals — with nothing
   in the UI or the API response indicating the range wasn't understood.
   
   Verified this against every affected prefix family (`Last`, `Next`, `Current
   <unit>`, `previous calendar <unit>`) with multiple casings each; all 
reproduce
   the same silent-drop behavior before this change.
   
   ### FIX
   
   Compare against a single `time_range.lower()` value instead of the raw 
string,
   so these checks are case-insensitive like the rest of the function. No other
   behavior changes — the original-cased `time_range` is still what gets used
   downstream, since the regex matching it later already handles case.
   
   ### TESTING INSTRUCTIONS
   
   Added regression cases to `test_get_since_until` in
   `tests/unit_tests/utils/date_parser_tests.py` covering lowercase, uppercase,
   and mixed-case variants of `Last`, `Next`, `Current <unit>`, and `previous
   calendar <unit>`, asserting they match their canonically-cased counterparts.
   
   ```
   $ python -m pytest tests/unit_tests/utils/date_parser_tests.py -q
   42 passed
   ```
   
   Confirmed the new assertions fail without the fix (`git stash` the source
   change, rerun): 1 failed, 41 passed.
   
   `ruff check`/`ruff format`/`mypy` clean on both changed files.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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]

Reply via email to