Skip to content

fix: skip invalid date filters in DataTable#657

Merged
rsbh merged 2 commits intomainfrom
fix_invalid_date_filter
Feb 26, 2026
Merged

fix: skip invalid date filters in DataTable#657
rsbh merged 2 commits intomainfrom
fix_invalid_date_filter

Conversation

@rsbh
Copy link
Member

@rsbh rsbh commented Feb 26, 2026

Summary

  • Skip invalid date filters entirely in queryToTableState (client mode) and transformToDataTableQuery (server mode) instead of sending empty stringValue
  • Validate date using dayjs.isValid() before including in filter query
  • Add tests for invalid date filter handling

Follows up on #656

Test plan

  • Add a date filter column to DataTable
  • Type an invalid date in the filter chip input
  • Verify filter is skipped (no empty stringValue sent, all rows visible)
  • Verify valid dates still filter correctly

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced date filter validation to properly handle invalid dates and edge cases in data table operations.
  • Tests

    • Added comprehensive test coverage for date filter validation, including invalid date handling and filter preservation scenarios.

rsbh and others added 2 commits February 26, 2026 13:38
…taTableQuery

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
apsara Building Building Preview, Comment Feb 26, 2026 8:10am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2026

📝 Walkthrough

Walkthrough

The PR adds date filter validation to data-table utility functions using dayjs to ensure only valid dates are preserved during query transformations. Tests are expanded to cover date filter edge cases and new getDataType functionality.

Changes

Cohort / File(s) Summary
Date Filter Validation Logic
packages/raystack/components/data-table/utils/index.tsx
Added dayjs-based date validation in queryToTableState and transformToDataTableQuery to filter out invalid dates while preserving valid date-type filters during transformations.
Filter Operations Test Coverage
packages/raystack/components/data-table/utils/__tests__/filter-operations.test.tsx
Reformatted and expanded test suite with new coverage for getDataType function and edge cases for date-related getFilterValue behavior, including invalid date and default value handling.
Integration Test Coverage
packages/raystack/components/data-table/utils/__tests__/index.test.tsx
Added test cases validating date filter preservation and invalidation in queryToTableState and transformToDataTableQuery transformations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • rohanchkrabrty
  • singh-pk
  • paanSinghCoder

Poem

🐰 Hopping through filters with dayjs so bright,
Validating dates to keep them just right,
Invalid ones vanish, the valid ones stay,
Tests cover edge cases throughout the day!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: skipping invalid date filters in DataTable, which aligns with the core changes in both queryToTableState and transformToDataTableQuery functions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_invalid_date_filter

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/raystack/components/data-table/utils/index.tsx (1)

24-28: Consider handling select filters consistently with transformToDataTableQuery.

The transformToDataTableQuery function (line 197) explicitly allows select filters through unconditionally with if (data._type === FilterType.select) return true;, but queryToTableState does not have this handling. This means empty select filter values would be filtered out in client mode but preserved in server mode.

If this inconsistency is intentional (different requirements for client vs server), consider adding a comment to document this behavior. Otherwise, you may want to align the logic:

💡 Suggested change for consistency
 const columnFilters =
   query.filters
     ?.filter(data => {
+      if (data._type === FilterType.select) return true;
       if (data._type === FilterType.date) return dayjs(data.value).isValid();
       if (data.value !== '') return true;
       return false;
     })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/raystack/components/data-table/utils/index.tsx` around lines 24 -
28, In queryToTableState, align its filter logic with transformToDataTableQuery
by explicitly allowing select filters: update the anonymous filter inside
queryToTableState to return true when data._type === FilterType.select (or, if
the difference is intentional, add a clear comment in queryToTableState
explaining why selects are excluded) so select filters aren’t dropped in client
mode; reference the FilterType.select symbol and the queryToTableState and
transformToDataTableQuery functions when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/raystack/components/data-table/utils/index.tsx`:
- Around line 24-28: In queryToTableState, align its filter logic with
transformToDataTableQuery by explicitly allowing select filters: update the
anonymous filter inside queryToTableState to return true when data._type ===
FilterType.select (or, if the difference is intentional, add a clear comment in
queryToTableState explaining why selects are excluded) so select filters aren’t
dropped in client mode; reference the FilterType.select symbol and the
queryToTableState and transformToDataTableQuery functions when making the
change.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d102a3 and 6fb2ebe.

📒 Files selected for processing (3)
  • packages/raystack/components/data-table/utils/__tests__/filter-operations.test.tsx
  • packages/raystack/components/data-table/utils/__tests__/index.test.tsx
  • packages/raystack/components/data-table/utils/index.tsx

@rsbh rsbh merged commit 7d24df8 into main Feb 26, 2026
5 checks passed
@rsbh rsbh deleted the fix_invalid_date_filter branch February 26, 2026 10:10
rsbh added a commit that referenced this pull request Feb 26, 2026
* fix: skip invalid date filters in queryToTableState and transformToDataTableQuery

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add tests for invalid date filter validation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants