fix(client): pass type mapping through zScan#3277
Conversation
6be35de to
784e02c
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 784e02c. Configure here.
| sortedSetMembers.set(value.toString(), score); | ||
| } | ||
| } | ||
| assert.deepEqual(sortedSetMembers, new Map([['member', '1.5']])); |
There was a problem hiding this comment.
Test asserts string score but gets Buffer
Medium Severity
The zScanIterator section of this test combines BLOB_STRING: Buffer and DOUBLE: String type mappings, then asserts the score equals the string '1.5'. In RESP2 (the default), scores arrive as blob strings, so the decoder converts them to Buffer via the BLOB_STRING: Buffer mapping. When transformDoubleReply[2] then processes this with DOUBLE: String, its case String branch returns the reply as-is — which is already a Buffer, not a string. The assert.deepEqual against new Map([['member', '1.5']]) would fail because the actual score is Buffer.from('1.5'). This test was never run against a real Redis server per the PR description.
Reviewed by Cursor Bugbot for commit 784e02c. Configure here.


Summary
typeMappingthroughZSCANsorted-set reply transformationZSCANregression forRESP_TYPES.DOUBLEwithTypeMapping({ [RESP_TYPES.BLOB_STRING]: Buffer })Closes #2370
Validation
node --import tsx -e "const assert = require(''node:assert/strict''); const ZSCAN = require(''./packages/client/lib/commands/ZSCAN.ts'').default; const { RESP_TYPES } = require(''./packages/client/lib/RESP/decoder.ts''); assert.deepEqual(ZSCAN.transformReply([''0'', [''member'', ''1.5'']], undefined, { [RESP_TYPES.DOUBLE]: String }), { cursor: ''0'', members: [{ value: ''member'', score: ''1.5'' }] }); assert.equal(Buffer.from(''0'').toString(), ''0''); console.log(''scan type mapping checks ok'');"npm run lint:changednpm run buildRedis-backed iterator tests were not run locally because Docker is not installed in this environment.
Note
Low Risk
Low-risk bugfixes to reply transformation and iterator cursor handling; main risk is subtle behavior change in scan loop termination when cursors are non-strings under type mapping/RESP3.
Overview
Ensures
ZSCAN.transformReplyforwardstypeMappinginto the sorted-set reply transformer so mappedDOUBLEscores (e.g. toString) are honored.Updates all scan iterators (
scanIterator,hScanIterator,hScanNoValuesIterator,sScanIterator,zScanIterator) to compare cursors viacursor.toString()so iteration terminates correctly even when cursors are returned as non-strings under type mapping.Adds regression tests covering
ZSCANtype-mapped scores and end-to-end iterator behavior withwithTypeMapping(Blob strings asBuffer, doubles asString).Reviewed by Cursor Bugbot for commit 784e02c. Bugbot is set up for automated code reviews on this repo. Configure here.