Repository navigation
fix(client): require XADD TRIM strategy to match the command grammar - #3418
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2af5c789a8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| * Required by the XADD grammar: without MAXLEN or MINID the server parses | ||
| * the threshold as the entry ID instead of trimming. | ||
| */ | ||
| strategy: 'MAXLEN' | 'MINID'; |
There was a problem hiding this comment.
Update the shared NOMKSTREAM trim cases
Because XADD_NOMKSTREAM delegates to parseXAddArguments, this required property also applies to its co-located argument tests, but four cases in XADD_NOMKSTREAM.spec.ts still omit strategy and assert the same malformed wire arguments this change is fixing. The test runner transpiles specs without type-checking, so those assertions continue to pass and leave the suite explicitly blessing invalid XADD grammar; update the NOMKSTREAM cases alongside these XADD cases.
AGENTS.md reference: AGENTS.md:L56-L59
Useful? React with 👍 / 👎.
|
@abhijeet117 Thanks for the PR. We’ll review it when we have capacity. |
|
Thanks for the fix and the clear write-up — the underlying problem is real. Before we merge, a few bounded items:
Note that |
nkaradzhov
left a comment
There was a problem hiding this comment.
Requesting changes: make the parseXAddArguments strategy push unconditional, fix the residual strategy-less TRIM cases in XADD.spec.ts and XADD_NOMKSTREAM.spec.ts, and add a release-note entry for the compile-time break. Details in my comment above.
|
Thanks — you've addressed all the points (unconditional strategy push, the remaining specs, and the release note). LGTM. |
SummaryXAddOptions made TRIM.strategy optional while the XADD grammar makes MAXLEN|MINID mandatory inside the trim block. Omitting it emitted a bare number that the server parses as the entry ID (streamParseStrictIDOrReply), so the command added a wrong-ID entry with garbage fields or errored instead of trimming. strategy is now required, matching the XTRIM client API; five spec cases asserted the malformed argv and were corrected.## TestingCompile-time regression test rejects a strategy-less TRIM object: it compiled on master (TS2578) and fails after the fix. Verified against xadd.json and t_stream.c; parser assertions, type tests, build and lint run locally; Docker-backed integration tests run in CI.## Checklist- bug reproduced before fix- root cause identified- bug fixed- tests passed
Note
Medium Risk
Breaking TypeScript API for callers that passed
TRIMwithoutstrategy, but the old behavior sent invalid commands to Redis; runtime behavior is corrected for properly typed callers.Overview
Fixes incorrect
XADDargv whenTRIMomittedMAXLEN/MINID. The client previously allowedTRIMwith onlythreshold, which produced a bare number before the entry ID; Redis treats that as the stream ID, so adds could use wrong IDs or fail instead of trimming.XAddOptions.TRIM.strategyis now required (aligned withXTRIM), andparseXAddArgumentsalways emitsMAXLENorMINIDbefore the threshold and related trim tokens. Unit expectations inXADDandXADD_NOMKSTREAMspecs were updated for modifier, limit, and policy cases; a compile-time test intypes-testsrejects strategy-lessTRIMobjects.Reviewed by Cursor Bugbot for commit a0b0ad7. Bugbot is set up for automated code reviews on this repo. Configure here.
Release note
XADD TRIM.strategy is now required at compile time: MAXLEN/MINID is mandatory in the XADD grammar, so callers omitting it would previously emit a bare threshold the server parsed as an entry ID.