Skip to content

fix(table-core): prototype-named column ids poisoning row value caches#1

Closed
artchen-db wants to merge 1 commit into
mainfrom
hasownproperty-fix
Closed

fix(table-core): prototype-named column ids poisoning row value caches#1
artchen-db wants to merge 1 commit into
mainfrom
hasownproperty-fix

Conversation

@artchen-db

Copy link
Copy Markdown
Owner

Problem

A column whose id equals an Object.prototype member (e.g. hasOwnProperty) crashes filtering/sorting:

TypeError: this._valuesCache.hasOwnProperty is not a function

Root cause

Per-row caches are plain {} objects probed with cache.hasOwnProperty(columnId), then written keyed by column id. When columnId === "hasOwnProperty", the write shadows the inherited method, so the next probe invokes a cached value as a function and throws.

Fix

Initialize the caches (_valuesCache, _uniqueValuesCache, _groupingValuesCache) with Object.create(null) and read them via Object.prototype.hasOwnProperty.call(...). Also null-prototype _getAllCellsByColumnId so ids like toString/constructor resolve correctly when read via bracket access in getColumnCanGlobalFilter. This removes the entire prototype-collision class for these caches.

Tests

Added tests/prototypeColumnId.test.ts covering getValue, getUniqueValues, and the cascading-failure case across hasOwnProperty, toString, constructor, valueOf, __proto__, isPrototypeOf. Fails without the fix, passes with it. Full table-core suite (27 tests) and tsc --noEmit pass.

Row value caches (_valuesCache, _uniqueValuesCache, _groupingValuesCache)
were plain objects probed with cache.hasOwnProperty(columnId). A column
whose id collided with an Object.prototype member (e.g. hasOwnProperty)
shadowed the inherited method on write, so the next probe invoked a cached
value as a function and threw TypeError, crashing filtering and sorting.

Caches are now created with Object.create(null) and read via
Object.prototype.hasOwnProperty.call. _getAllCellsByColumnId is likewise
null-prototyped so prototype-named ids resolve correctly when read via
bracket access in getColumnCanGlobalFilter.

Co-authored-by: Isaac
@autofix-troubleshooter

Copy link
Copy Markdown

Hi! I'm the autofix logoautofix.ci troubleshooter bot.

It looks like you correctly set up a CI job that uses the autofix.ci GitHub Action, but the autofix.ci GitHub App has not been installed for this repository. This means that autofix.ci unfortunately does not have the permissions to fix this pull request. If you are the repository owner, please install the app and then restart the CI workflow! 😃

@artchen-db

Copy link
Copy Markdown
Owner Author

Superseded by upstream PR against TanStack/table.

@artchen-db artchen-db closed this Jun 19, 2026
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