fix(client): parse xInfoGroups replies by field#3281
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 311dbc6. Configure here.
| }); | ||
| }, | ||
| 2: (reply: Array<Array<BlobStringReply | NumberReply | NullReply>>) => | ||
| reply.map(group => transformTuplesReply(group as unknown as ArrayReply<BlobStringReply>)) as unknown as XInfoGroupsReply['DEFAULT'], |
There was a problem hiding this comment.
Transformer returns null-prototype objects breaking integration test
Medium Severity
transformTuplesReply returns objects created with Object.create(null) (null prototype), but the existing integration test at line 62 expects a regular object literal with Object.prototype. Since the test uses strict assert (i.e., deepStrictEqual), and Node.js 20+ compares [[Prototype]] with ===, the test will fail for all Redis versions. Additionally, for pre-7 Redis, entries-read and lag fields won't exist as properties at all (whereas the old positional code always included them as undefined), causing a further mismatch with the test expectation.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 311dbc6. Configure here.


Summary
Updates the RESP2
XINFO GROUPStransformer to build each group from the returned field names instead of fixed array positions.This keeps existing fields working, preserves Redis 7's
entries-readandlagfields, and makes the transformer tolerate nullable lag values as documented by Redis. It also corrects the reply type forlast-delivered-idto a blob string and allowslagto be null.Closes #2388.
Redis command reference: https://redis.io/docs/latest/commands/xinfo-groups/
Validation
node -r ts-node/register/transpile-onlytransformer check for Redis 7entries-read/lagfieldsnpm run lint:changednpm run buildgit diff --checkI also attempted
npx mocha --require ts-node/register/transpile-only packages/client/lib/commands/XINFO_GROUPS.spec.ts --grep transformReply, but this repo starts its Docker-backed Redis test environment in global hooks before grep-selected tests run. It failed locally atspawn docker ENOENTbecause Docker is not installed in this environment.Note
Medium Risk
Changes the RESP2 reply transformer and types for
XINFO GROUPS, which can affect downstream consumers that rely on the previous shape/typing or on positional parsing; behavior should improve but touches command decoding logic.Overview
Updates
XINFO GROUPSRESP2 reply handling to build each group object by field name usingtransformTuplesReply, instead of reading fixed tuple positions.Adjusts the reply typing to match Redis behavior (
last-delivered-idas a blob string;lagnullable) and adds unit tests covering both pre-Redis-7 and Redis-7+ fields (entries-read,lag) including null values.Reviewed by Cursor Bugbot for commit 311dbc6. Bugbot is set up for automated code reviews on this repo. Configure here.