Repository navigation
fix: send EXPANSION keyword in BF.RESERVE - #602
Conversation
Without the keyword the server ignores the trailing value and creates the filter with the default expansion rate. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis 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. |
The server ignores a stray value without the EXPANSION keyword and still replies OK, so read the expansion rate back through BF.INFO on standalone and cluster.
mgravell
left a comment
There was a problem hiding this comment.
Thanks for this - a good catch, and a clean fix. This has been silently wrong since the Bloom commands were first written: the server looks EXPANSION up by keyword and ignores a stray value while still replying OK, so nothing ever flagged it. Thanks also for calling out the expansion + nonscaling behaviour change in the description; we'll carry that into the release notes.
I've pushed one extra commit to your branch (33ce98b), I hope that's OK: TestReserveWithExpansion and TestReserveWithExpansionAsync. Because the server accepts the malformed command, an args-level test can't tell whether the option took effect, so these reserve a filter with expansion: 4 and read the rate back via BF.INFO, on standalone and cluster. They fail without your one-line fix and pass with it. Your builder test is unchanged.
Reserve/ReserveAsyncdo not apply theexpansionargument: the filter is created with the server's default expansion rate, and no error is returned.Root cause:
BloomCommandBuilder.Reserveappends the bare value, producingBF.RESERVE key 0.01 1000 4. The documented syntax isBF.RESERVE key error_rate capacity [EXPANSION expansion] [NONSCALING], and RedisBloom looks the option up by itsEXPANSIONkeyword, so a value without it is ignored.Fix: add
BloomArgs.EXPANSIONbefore the value, as theBF.INSERTpath already does. Signatures and defaults are unchanged.One consequence: a call that passes both a non-zero
expansionandnonscaling: trueused to succeed (the expansion was ignored). The server now sees both options and repliesNonscaling filters cannot expand.Test:
TestReserveWithExpansionArgsasserts the serialized arguments. It fails before the change and passes after (net8.0). The server behavior described above comes from reading the RedisBloom source; the integration tests were not run against a live server.Disclosure: this change was prepared with the assistance of an AI tool (Claude) and has not been reviewed line by line by a human before submission.
Note
Medium Risk
Fixes incorrect Redis command encoding for reserve calls; may surface new server errors when expansion and nonscaling are combined.
Overview
Fixes
BF.RESERVEso theexpansionoption is actually applied on the server.BloomCommandBuilder.Reservepreviously appended only the numeric value, which RedisBloom ignores; it now inserts theEXPANSIONkeyword before the value, matching documented syntax and the existingBF.INSERTbuilder.A unit test (
TestReserveWithExpansionArgs) locks in the serialized arguments. Behavior change: callers who set bothexpansionandnonscaling: truemay now get a server error where the expansion was silently ignored before.Reviewed by Cursor Bugbot for commit d2f6b58. Bugbot is set up for automated code reviews on this repo. Configure here.