From c87b4b9e24655a8b96ea4c09c8f36496ae08e250 Mon Sep 17 00:00:00 2001 From: eeshsaxena <139802361+eeshsaxena@users.noreply.github.com> Date: Sat, 8 Aug 2026 11:50:30 +0530 Subject: [PATCH] fix: order legacy filter date range by parsed datetime, not string _convert_date_value ordered the range with min/max on the raw date strings, which only matches chronological order for zero-padded ISO YYYY-MM-DD. Since _validate_date accepts any dateutil-parseable format, a non-ISO input like 9/1/2023 vs 10/1/2023 sorted lexicographically and produced a reversed range. Compare parsed datetimes instead. Fixes #9567. --- apps/api/plane/utils/filters/converters.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/api/plane/utils/filters/converters.py b/apps/api/plane/utils/filters/converters.py index 4d37c2b0b17..7055d920bb4 100644 --- a/apps/api/plane/utils/filters/converters.py +++ b/apps/api/plane/utils/filters/converters.py @@ -306,8 +306,13 @@ def _convert_date_value(self, field_name: str, values: List[str], strict: bool = result = {} if len(after_dates) == 1 and len(before_dates) == 1 and len(exact_dates) == 0: # Simple range: one after and one before - start_date = min(after_dates[0], before_dates[0]) - end_date = max(after_dates[0], before_dates[0]) + # Order the bounds chronologically by comparing parsed datetimes, not the + # raw strings: _validate_date accepts non-ISO formats that do not sort + # lexicographically (e.g. "9/1/2023" vs "10/1/2023"). + if dateutil_parse(after_dates[0]) <= dateutil_parse(before_dates[0]): + start_date, end_date = after_dates[0], before_dates[0] + else: + start_date, end_date = before_dates[0], after_dates[0] self._add_rich_filter(result, field_name, "range", [start_date, end_date]) elif len(exact_dates) == 1 and len(after_dates) == 0 and len(before_dates) == 0: # Single exact date