fix(explore): prevent TypeError when chart dimension returns empty string#38276
fix(explore): prevent TypeError when chart dimension returns empty string#38276
Conversation
Code Review Agent Run #00eb26Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
| dataIndex: | ||
| typeof column.id === 'string' && column.id.includes('.') | ||
| ? column.id.split('.') | ||
| : column.id, |
There was a problem hiding this comment.
What is the type column id if not a string? Should we make it so that it always is a string?
There was a problem hiding this comment.
Here's the docs for reference. https://react-table-v7-docs.netlify.app/docs/api/useTable#column-properties
There was a problem hiding this comment.
It is already defined as string, probably this check is redundant, I'll remove it
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review Agent Run #f0f4cfActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Code Review Agent Run #7195d7Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
🎪 Showtime deployed environment on GHA for 007b33c • Environment: http://35.91.65.234:8080 (admin/admin) |
SUMMARY
When a chart dimension returns an empty string; for example, using coalesce(address_line2, '') as a dimension on a Line Chart; the Results tab in the Explore view crashes with TypeError: n.includes is not a function, and the loading spinner appears frozen.
The root cause is in useTableColumns, which uses id: key || index as a fallback when the column key is empty. Since empty string is falsy in JavaScript, the expression evaluates to index; a number. This numeric ID then flows downstream into mapColumns in TableCollection/utils.tsx, where column.id?.includes('.') is called. Optional chaining (?.) only guards against null and undefined, not non-string types, so calling .includes() on a number throws a TypeError.
The fix applies two layers of defense:
At the source ([DataTableControl/index.tsx]): Coerce the fallback index to a string with String(index), ensuring column.id is always a string regardless of whether the column key is empty.
At the call site ([TableCollection/utils.tsx]: Add an explicit typeof column.id === 'string' guard before calling .includes('.'), so that even if a numeric ID somehow reaches this code path in the future, it won't crash.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
before.mp4
after.mov
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION