Skip to content

fix(client): parse xInfoGroups replies by field#3281

Open
raashish1601 wants to merge 1 commit into
redis:masterfrom
raashish1601:codex/2388-xinfo-groups-transform
Open

fix(client): parse xInfoGroups replies by field#3281
raashish1601 wants to merge 1 commit into
redis:masterfrom
raashish1601:codex/2388-xinfo-groups-transform

Conversation

@raashish1601
Copy link
Copy Markdown
Contributor

@raashish1601 raashish1601 commented May 17, 2026

Summary

Updates the RESP2 XINFO GROUPS transformer to build each group from the returned field names instead of fixed array positions.

This keeps existing fields working, preserves Redis 7's entries-read and lag fields, and makes the transformer tolerate nullable lag values as documented by Redis. It also corrects the reply type for last-delivered-id to a blob string and allows lag to be null.

Closes #2388.

Redis command reference: https://redis.io/docs/latest/commands/xinfo-groups/

Validation

  • direct node -r ts-node/register/transpile-only transformer check for Redis 7 entries-read/lag fields
  • npm run lint:changed
  • npm run build
  • git diff --check

I 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 at spawn docker ENOENT because 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 GROUPS RESP2 reply handling to build each group object by field name using transformTuplesReply, instead of reading fixed tuple positions.

Adjusts the reply typing to match Redis behavior (last-delivered-id as a blob string; lag nullable) 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.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

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'],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 311dbc6. 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.

Add support for lag and entries-read results from XINFO GROUPS in Redis 7

1 participant