Skip to content

fix(filters): order date range by parsed datetime, not string comparison - #9568

Open
Badri467 wants to merge 2 commits into
makeplane:previewfrom
Badri467:fix/legacy-filter-date-range-ordering
Open

fix(filters): order date range by parsed datetime, not string comparison#9568
Badri467 wants to merge 2 commits into
makeplane:previewfrom
Badri467:fix/legacy-filter-date-range-ordering

Conversation

@Badri467

@Badri467 Badri467 commented Aug 7, 2026

Copy link
Copy Markdown

Description

LegacyToRichFiltersConverter._convert_date_value ordered date range bounds using min()/max() on raw strings, which is only correct for zero-padded ISO YYYY-MM-DD. Since _validate_date accepts any dateutil-parseable format, non-ISO inputs produced a reversed range that matched nothing.

Before: ["9/1/2023;after", "10/1/2023;before"]10/1/2023,9/1/2023 (reversed)
After: ["9/1/2023;after", "10/1/2023;before"]2023-09-01,2023-10-01 (correct)

Fix: parse both bounds with dateutil_parse, compare datetime objects, emit ISO YYYY-MM-DD strings.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Test Scenarios

  • Verified bug: min("9/1/2023", "10/1/2023") returns "10/1/2023" because '1' < '9' lexicographically → reversed range
  • Applied fix and confirmed correct output: 2023-09-01,2023-10-01
  • ISO input (2023-09-01;after, 2023-12-31;before) still works correctly
  • Added two unit tests in plane/tests/unit/utils/test_legacy_filter_converter.py

References

Fixes #9567

Summary by CodeRabbit

  • Bug Fixes

    • Improved date-range filtering to correctly order and format date values, including non-ISO date ranges.
    • Preserved accurate behavior for date ranges already using ISO-formatted dates.
  • Tests

    • Added coverage to verify correct chronological ordering for supported date formats.

@CLAassistant

CLAassistant commented Aug 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3bb92a52-0b96-4c86-9c53-34fb662ccc69

📥 Commits

Reviewing files that changed from the base of the PR and between e7406b9 and 3088549.

📒 Files selected for processing (1)
  • apps/api/plane/utils/filters/converters.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/api/plane/utils/filters/converters.py

📝 Walkthrough

Walkthrough

The legacy filter converter parses date bounds before ordering them, normalizes the output to YYYY-MM-DD, and adds tests for non-ISO and ISO date ranges.

Changes

Date range ordering

Layer / File(s) Summary
Chronological date range conversion
apps/api/plane/utils/filters/converters.py, apps/api/plane/tests/unit/utils/test_legacy_filter_converter.py
The converter orders parsed date bounds chronologically and formats them as YYYY-MM-DD. Unit tests cover non-ISO ordering and ISO date handling.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: dheeru0198

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the date-range ordering fix implemented in the pull request.
Description check ✅ Passed The description explains the bug, fix, test scenarios, and linked issue, and identifies the change as a bug fix.
Linked Issues check ✅ Passed The implementation and tests satisfy issue #9567 by ordering parsed dates chronologically and preserving ISO output behavior.
Out of Scope Changes check ✅ Passed All reported changes directly support the linked issue and the stated objective of fixing legacy date-range ordering.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/api/plane/utils/filters/converters.py`:
- Around line 309-315: Update the date range ordering in the conversion logic
using after_dt and before_dt so both parsed values are converted to date-only
values before min() and max(). Preserve the existing YYYY-MM-DD formatting and
ensure mixed naive and timezone-aware inputs no longer raise TypeError.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a3a74fe0-35a6-465c-9e04-f74308a16d8c

📥 Commits

Reviewing files that changed from the base of the PR and between 31853ab and e7406b9.

📒 Files selected for processing (2)
  • apps/api/plane/tests/unit/utils/test_legacy_filter_converter.py
  • apps/api/plane/utils/filters/converters.py

Comment thread apps/api/plane/utils/filters/converters.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Legacy filter converter orders date ranges by string comparison, reversing non-ISO date inputs

2 participants