Repository navigation
fix(client): return null from vector set commands for a missing key or element - #3535
Conversation
…r element When the vector set or the element does not exist, the server replies with nil, and the transforms read the reply anyway. vEmbRaw() threw a TypeError on both protocols, and on RESP2 vEmb(), vInfo() and vLinksWithScores() threw too. vLinks() already returned null. Return null for a nil reply in each command's transform. The VEMB check lives in VEMB.ts, so the shared transformDoubleArrayReply, which the t-digest commands also use, is unchanged. The reply types of vEmb, vEmbRaw, vInfo, vLinks and vLinksWithScores now include null. Fixes redis#3533
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Thanks for the PR. It follows the approach discussed in #3533, and the changes look correct to me. The new types-test fails on master and passes here. A few things for @nkaradzhov to weigh before merging:
|
|
On the On the cluster cases: I copied the |
Description
Fixes #3533
When the vector set or the element doesn't exist, the server replies with nil and these transforms read it anyway.
vEmbRaw()throws aTypeErroron both protocols, so it breaks on the default RESP3 client too. On RESP2,vEmb(),vInfo()andvLinksWithScores()throw the same way; on RESP3 they have no transform and already returnnull, likevLinks().With
redis:8, on master:and every one of these calls returns
nullon this branch.Each transform now returns
nullfor a nil reply, likeZRANK_WITHSCORE. VEMB gets its own transform inVEMB.ts, sotransformDoubleArrayReply, which the t-digest commands share, stays as it is. The reply types of the five commands now includenull; forvLinksthat's the only change.The tests call each command on a missing key and a missing element with
testUtils.testAll, on RESP2 and RESP3, and expectnull. The RESP2 ones andvEmbRawon RESP3 fail on master. There's also a types-test that checks each reply type acceptsnull.npm run build && npm testpasses, lint is clean.Checklist
npm testpass with this change (including linting)?Note
Low Risk
Behavioral bugfix in vector-set reply handling and typings; no auth, persistence, or infrastructure changes.
Overview
Fixes TypeError crashes when vector-set commands get a Redis nil reply for a missing key or element.
vEmb,vEmbRaw,vInfo,vLinks, andvLinksWithScoresnow returnnullinstead of running transforms on nil (matching patterns like other commands that handle null replies).RESP2 transforms gain early
reply === nullguards;VEMBuses a dedicated RESP2 transform so sharedtransformDoubleArrayReplystays unchanged for t-digest. Reply typings are widened to| nullon RESP2 and RESP3.Integration tests cover missing key/element on both RESP versions; a
types-testsfile asserts each client method’s return type acceptsnull.Reviewed by Cursor Bugbot for commit effe221. Bugbot is set up for automated code reviews on this repo. Configure here.