Skip to content

fix(client): preserve empty scan match patterns - #3460

Open
jakezwang wants to merge 1 commit into
redis:masterfrom
jakezwang:fix-empty-scan-match
Open

jakezwang wants to merge 1 commit into
redis:masterfrom
jakezwang:fix-empty-scan-match

Conversation

@jakezwang

@jakezwang jakezwang commented Sep 19, 2026

Copy link
Copy Markdown

Description

scan('0', { MATCH: '' }) currently omits MATCH, returning all keys instead of matching only the empty key. The shared argument helpers also affect hash, set, and sorted-set scans.

Preserve an explicitly empty pattern in both helpers and add regressions for each. Omitted patterns and non-empty patterns keep their existing behavior.

Validation: both new tests fail before the fix. The 905 command argument/reply tests pass on Node 20, 22, and 24. Build, changed-file lint, and command JSDoc checks pass on Node 24. Native Redis 8.4 checks pass for scan, hScan, sScan, zScan, and scanIterator; the related repository suites pass 88 tests with one cluster test skipped. The full Docker matrix was not run because host networking is unavailable locally.


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

No API or documentation change is needed.


Note

Low Risk
Small, targeted fix to optional argument serialization with new unit tests; no auth or data-model changes.

Overview
Fixes scan-family commands dropping an explicit empty MATCH pattern. Previously { MATCH: '' } was treated like no MATCH because the helpers used truthiness, so Redis saw an unfiltered scan instead of MATCH with an empty string.

parseScanArguments and pushScanArguments now emit MATCH when MATCH !== undefined, so empty strings are preserved. Omitted MATCH and non-empty patterns behave as before. The same helpers back SCAN, HSCAN, SSCAN, and ZSCAN.

Regression tests cover empty MATCH for SCAN argument parsing and pushScanArguments.

Reviewed by Cursor Bugbot for commit 97010cf. Bugbot is set up for automated code reviews on this repo. Configure here.

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.

1 participant