fix(query-core): reject longer partial array keys by gwagjiug · Pull Request #11502 · TanStack/query · GitHub
Skip to content

fix(query-core): reject longer partial array keys - #11502

Merged
TkDodo merged 2 commits into
TanStack:mainfrom
gwagjiug:fix/partial-match-key-array-length
Sep 15, 2026
Merged

TkDodo merged 2 commits into
TanStack:mainfrom
gwagjiug:fix/partial-match-key-array-length

Conversation

@gwagjiug

@gwagjiug gwagjiug commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Changes

partialMatchKey previously iterated over every element in the filter key without first checking whether the candidate array was long enough. A filter such as ['todos', undefined] therefore matched the shorter ['todos'] key because both missing and explicit array elements evaluate to undefined.

  • Return false when an array filter is longer than the candidate array.
  • Add a regression test for a trailing undefined filter element.
  • Add a patch changeset for @tanstack/query-core.

Validation: pnpm run test:pr with Node 24.16.0.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes

    • Fixed partial query-key matching so longer filters with trailing undefined values no longer match shorter query keys.
    • Improved query matching accuracy when the filter contains more array elements than the target key.
    • Prevented incorrect matches caused by differences in query-key length.
  • Tests

    • Added coverage for preventing incorrect matches between query keys of different lengths, including keys with trailing undefined values.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

@gwagjiug gwagjiug changed the title fix(query-core): reject longer partial array keys 🤖🤖🤖 fix(query-core): reject longer partial array keys Sep 15, 2026
@nx-cloud

nx-cloud Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit e8f8da5

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 2m 20s View ↗

☁️ Nx Cloud last updated this comment at 2026-09-15 16:37:09 UTC

@pkg-pr-new

pkg-pr-new Bot commented Sep 15, 2026

Copy link
Copy Markdown

Comment thread packages/query-core/src/__tests__/utils.test.tsx Outdated
@TkDodo
TkDodo merged commit cbf77bf into TanStack:main Sep 15, 2026
3 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 15, 2026
@gwagjiug
gwagjiug deleted the fix/partial-match-key-array-length branch September 16, 2026 09:07
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.

3 participants