Repository navigation
fix(client): align RedisClientOptions RESP default with RedisClientType - #3303
Merged
nkaradzhov merged 3 commits intoJun 1, 2026
Merged
nkaradzhov merged 3 commits into
nkaradzhov merged 3 commits into
Conversation
RedisClientOptions defaulted RESP to RespVersions (2 | 3) while RedisClientType and createClient default to 3. Annotating options with RedisClientOptions caused createClient(options) to return a client incompatible with RedisClientType, especially with exactOptionalPropertyTypes. Fixes redis#3300 Co-authored-by: Cursor <cursoragent@cursor.com>
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
Contributor
Author
|
Hello, I checked the issue and investigated the relevant method. I would like to take this up and submit a fix. Could you assign it to me? |
… test Applied on top of redis#3303 to address review findings: * `packages/test-utils/lib/index.ts` — `cleanupAclUsers` parameter was `Partial<RedisClientOptions>`, which after redis#3303 narrows `RESP` to `3`. Internal callers pass `Partial<RedisClientOptions<M, F, S, RESP, ...>>` with the test's generic `RESP`, breaking the monorepo `tsc --build`. Widen to `Partial<RedisClientOptions<RedisModules, RedisFunctions, RedisScripts, RespVersions>>` so any `RESP` literal is accepted, as done for other internal RESP-erased call sites in redis#3303. * `enterprise-maintenance-manager.ts` — `import` / `type` / `import` ordering swapped to a clean import block followed by the local `AnyRedisClientOptions` alias. TS-valid either way; just less surprising for readers. * `create-client.types-test.ts` — broaden the regression. The original test only validated standalone (`RedisClientType` / `RedisClientOptions`). Add `Equal<…>`-style RESP-default parity assertions for cluster, sentinel, and pool so any future drift on those `*Options` interfaces fails compile. The function-signature pattern (`function f(opts: X): Y { return create(opts); }`) is still exercised for standalone and pool. Cluster and sentinel are explicitly omitted from that pattern because their `*Options` interfaces default `M`/`F`/`S` to `RedisModules`/`RedisFunctions`/`RedisScripts` (wide) while the `*Type` aliases default them to `{}` (narrow) — an asymmetry that is independent of redis#3300 and surfaces a separate `M`-invariance in cluster through `_handleAsk`. Captured in a comment so the next reader does not try to re-add those tests blind. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 0c7ad14. Configure here.
- Move types-test out of `lib/` to `packages/client/types-tests/` so it is not compiled into `dist/` by the production build or picked up by typedoc. - Make parity assertions actually fail on drift: strict `Equal` returning `true | false` (never `never`), wrapped in `Assert<T extends true>`. The previous `Equal<…, …>` returned `never` on mismatch, which `Assert<never>` would accept vacuously. Switched extraction to `infer` on every generic position so invariant generics (cluster) don't collapse the conditional to `never`. Each side now asserts against the literal `3` independently. - Dedupe the widened `RedisClientOptions` alias: export `AnyRedisClientOptions` from `lib/client` (replacing the private `ParsedRedisClientOptions` and the inline duplicates in `enterprise-maintenance-manager.ts`, `sentinel/index.ts`, `sentinel/pub-sub-proxy.ts`, and `test-utils`). - Restore `parseOptions` identity generic so caller-side narrowing (incl. `SocketOptions`) is preserved end-to-end: `static parseOptions<O extends AnyRedisClientOptions>(options: O): O`.
nkaradzhov
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
RedisClientOptionsRESP generic to3, matchingRedisClientType,createClient, andRedisClient.create.RedisClusterOptionsandRedisSentinelOptions.RespVersionsin internal code that must accept RESP2 clients.npm run test:typesin@redis/client).Test plan
npm run test:typesinpackages/clientnpx tsc --buildinpackages/clientnpm testin CIFixes #3300
Note
Low Risk
Type-level defaults and internal widening only; runtime behavior unchanged except consumers see stricter/narrower typings aligned with existing factory defaults.
Overview
Fixes #3300 by aligning public
*Optionsinterfaces with their matching*Typealiases and factories on RESP3 as the default.RedisClientOptions,RedisClusterOptions, andRedisSentinelOptions(and related node option types) now default theRESPgeneric to3instead of the fullRespVersionsunion, matchingRedisClientType,createClient, and cluster/sentinel factories. That restores patterns likefunction f(opts: RedisClientOptions): RedisClientTypewhen options are passed intocreateClient.A new exported
AnyRedisClientOptionswidensRESPtoRespVersionsfor internal paths that must accept any protocol version (URL parsing, maintenance manager, sentinel#createClient, pub-sub proxy, test-utils ACL cleanup).npm run test:typesruns compile-only checks undertypes-tests/(RESP default parity and the standalone factory return-type pattern);testin@redis/clientinvokes it before Mocha.Reviewed by Cursor Bugbot for commit ebf3ffb. Bugbot is set up for automated code reviews on this repo. Configure here.