fix: prevent crash in createSortedRowModel for unknown sorting column ids#6373
Merged
KevinVandy merged 1 commit intoJul 3, 2026
Merged
Conversation
… ids sorting.filter() force-cast table.getColumn(sort.id) to Column_Internal even when it returned undefined (e.g. a column removed while its sort state persisted), so column_getCanSort threw when dereferencing column.columnDef. Guard the lookup and treat unknown columns as unsortable instead of crashing.
Contributor
📝 WalkthroughWalkthroughThe availableSorting filter in createSortedRowModel now checks whether a column exists before calling column_getCanSort, preventing errors when sort state references non-existent columns. A new unit test suite verifies fallback to original order and partial sorting behavior when sort entries reference unknown or mixed valid/invalid column ids. ChangesSafe sort column handling
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
KevinVandy
approved these changes
Jul 3, 2026
|
View your CI Pipeline Execution ↗ for commit 812a763
☁️ Nx Cloud last updated this comment at |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Changes
createSortedRowModel'ssorting.filter(...)force-casttable.getColumn(sort.id)toColumn_Internaleven when the lookup returnedundefined(e.g. a column removed/renamed while itssortingstate still references the old id). Thatundefinedwas then passed straight intocolumn_getCanSort, which dereferencescolumn.columnDef.enableSortingand throws aTypeError, crashinggetSortedRowModel().This guards the lookup so an unknown sorting column id is simply treated as unsortable instead of crashing the whole row model.
Added
packages/table-core/tests/unit/features/row-sorting/createSortedRowModel.test.tscovering:getSortedRowModel()no longer throws whensortingreferences a nonexistent column id✅ Checklist
pnpm test:pr.