Fix data table crash by validating column IDs and coercing row IDs#1821
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the UI data table against malformed inputs by preventing TanStack column-definition construction from throwing on falsy column IDs and by ensuring row IDs are always strings for downstream string operations (e.g., keyboard navigation sentinel checks).
Changes:
- Coerces TanStack
getRowIdresults tostringto prevent runtime crashes whengetRowKeyreturns non-strings. - Generates a fallback, positional column
idwhencolumn.keyis missing/empty to avoid TanStack throwing on falsy IDs. - Adds/updates unit tests to cover both behaviors.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/ui/src/lib/data-table/grid/grid-constants.ts | Adds a defensive runtime check around summary-row ID detection. |
| libs/ui/src/lib/data-table/grid/grid-column-utils.tsx | Prevents crashes when col.key is missing by using optional chaining in metadata label lookup. |
| libs/ui/src/lib/data-table/grid/core/useJetstreamTable.ts | Forces getRowId to return a string to keep row-id operations consistent. |
| libs/ui/src/lib/data-table/grid/buildColumnDefs.ts | Normalizes/backs up TanStack column IDs to avoid crashes on falsy ids. |
| libs/ui/src/lib/data-table/grid/tests/useJetstreamTable.spec.tsx | Adds a test verifying row IDs are coerced to strings. |
| libs/ui/src/lib/data-table/grid/tests/buildColumnDefs.spec.ts | Adds a test verifying fallback column IDs when keys are missing/empty. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5dac949 to
67c3d7d
Compare
…ng row IDs to strings
67c3d7d to
9660829
Compare
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.
Ensure valid column IDs to prevent crashes when malformed data is encountered. Coerce row IDs to strings to maintain consistency during operations.