Skip to content

fix: send EXPANSION keyword in BF.RESERVE - #602

Merged
mgravell merged 2 commits into
redis:masterfrom
pcbeingused33:fix-bf-reserve-expansion
Nov 27, 2026
Merged

mgravell merged 2 commits into
redis:masterfrom
pcbeingused33:fix-bf-reserve-expansion

Conversation

@pcbeingused33

@pcbeingused33 pcbeingused33 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Reserve / ReserveAsync do not apply the expansion argument: the filter is created with the server's default expansion rate, and no error is returned.

Root cause: BloomCommandBuilder.Reserve appends the bare value, producing BF.RESERVE key 0.01 1000 4. The documented syntax is BF.RESERVE key error_rate capacity [EXPANSION expansion] [NONSCALING], and RedisBloom looks the option up by its EXPANSION keyword, so a value without it is ignored.

Fix: add BloomArgs.EXPANSION before the value, as the BF.INSERT path already does. Signatures and defaults are unchanged.

One consequence: a call that passes both a non-zero expansion and nonscaling: true used to succeed (the expansion was ignored). The server now sees both options and replies Nonscaling filters cannot expand.

Test: TestReserveWithExpansionArgs asserts 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.RESERVE so the expansion option is actually applied on the server. BloomCommandBuilder.Reserve previously appended only the numeric value, which RedisBloom ignores; it now inserts the EXPANSION keyword before the value, matching documented syntax and the existing BF.INSERT builder.

A unit test (TestReserveWithExpansionArgs) locks in the serialized arguments. Behavior change: callers who set both expansion and nonscaling: true may 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.

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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T10:35:36.504447Z 33ce98b New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

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 mgravell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@mgravell
mgravell merged commit 25a0011 into redis:master Nov 27, 2026
56 of 58 checks passed
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.

2 participants