Skip to content

fix(ruby): align FT search builder options with other GLIDE clients - #398

Merged
Aryex merged 4 commits into
mainfrom
agent/388/ft-search-builders
Oct 30, 2026
Merged

Aryex merged 4 commits into
mainfrom
agent/388/ft-search-builders

Conversation

@Aryex

@Aryex Aryex commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes FT Search builder options that silently dropped what the caller asked for, or crashed on a "not given" value. Behaviour now matches the other GLIDE clients (Python, Java, Node, Go). All changes are in Ruby-side request construction, before the command reaches GLIDE Core.

Also removes the "redis-rb conventions" rule from AGENTS.md: GLIDE clients are the reference for command behaviour.

Issue link

Changes

  • CreateOptions stopwords: (Search Module: Preserve explicit empty FT.CREATE stopword lists #386): [] used to be dropped, so the server used its default stopwords. It now sends STOPWORDS 0, which turns stopword removal off. nil still sends nothing.
  • AggregateOptions clauses: (Search Module: Leaking NoMethodError #387): the default is now nil, and nil means no clauses. Before, clauses: nil raised NoMethodError.
  • SearchOptions sort_order: (Search Module: Reject sort_order when sort_by is omitted #388): the default is now nil.
    • An explicit sort_order without sort_by raises ArgumentError, "sort_order requires sort_by". Before, it was silently ignored.
    • sort_by with no order now sends only SORTBY <field> and lets the server apply its default (ascending). Before, Ruby always added ASC. Results are unchanged.
  • AGENTS.md: removed the "Prefer matching redis-rb method signatures and return types" rule.
Behaviour Ruby (this PR) Python Java Node Go
stopwords: [] STOPWORDS 0 STOPWORDS 0 STOPWORDS 0 STOPWORDS 0 dropped
clauses: nil no clauses no clauses no clauses no clauses no clauses
order without sort field raises raises raises raises raises
sort field, no order SORTBY f SORTBY f SORTBY f SORTBY f SORTBY f

Limitations

  • Behaviour change: code that passes sort_order: without sort_by: used to be silently ignored and now raises.
  • No runtime type checks: wrong argument types, such as return_fields: "title" from Search Module: Leaking NoMethodError #387, aren't checked at runtime. Ruby relies on the documented YARD types, and none of the other clients validates these at runtime either.
  • No CHANGELOG entry: FT Search is new in this unreleased version.

Testing

  • Added unit tests:
    • test/unit/commands/search_builder_test.rb: test_create_options_stopwords_empty, test_create_options_rejects_empty_stopwords_with_no_stopwords, test_ft_create_builder_with_empty_stopwords
    • test/unit/commands/search_query_test.rb: test_sort_order_asc, test_sort_order_nil, test_sort_order_requires_sort_by, test_ft_search_sort_order_requires_sort_by (checks that nothing is sent), test_return_fields_empty, test_params_empty
    • test/unit/commands/search_aggregate_test.rb: test_aggregate_options_nil_clauses
  • Updated tests: existing tests now expect SORTBY <field> without ASC when no order is given. test_sort_by_default_asc_and_desc was renamed to test_sort_by_without_order_and_desc.
  • Removed: test_create_options_empty_stopwords_emits_nothing, which asserted the Search Module: Preserve explicit empty FT.CREATE stopword lists #386 bug.
  • Local run on Ruby 3.4: bundle exec rake test:unit (524 tests, 0 failures) and bundle exec rubocop (no offenses). Integration tests run in CI.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to an issue.
  • Commit message describe your changes
  • Commits are signed off (git commit -s) per the DCO.
  • Tests are added or updated.
  • CHANGELOG.md and documentation files are updated. (No CHANGELOG entry: FT Search is new in this unreleased version.)
  • Linters have been run (bundle exec rubocop) and pass.
  • Destination branch is correct - main.

Aryex pushed a commit that referenced this pull request Oct 30, 2026
Signed-off-by: Minh [C] Quang Le <lehminh@amazon.com>
@Aryex Aryex self-assigned this Oct 30, 2026
@Aryex
Aryex force-pushed the agent/388/ft-search-builders branch from b6576dc to 9342709 Compare October 30, 2026 14:52
Aryex added a commit that referenced this pull request Oct 30, 2026
Signed-off-by: Alex Le <alex.le@improving.com>
@Aryex Aryex changed the title fix(ruby): validate FT search builder options fix(ruby): align FT search builder options with other GLIDE clients Oct 30, 2026
@Aryex
Aryex force-pushed the agent/388/ft-search-builders branch 4 times, most recently from 642dc85 to d34728f Compare October 30, 2026 15:41
Aryex added 2 commits October 30, 2026 15:44
- CreateOptions: `stopwords: []` sends `STOPWORDS 0` instead of being
  dropped, matching Python, Java and Node (#386).
- AggregateOptions: `clauses` defaults to nil, and nil means no clauses
  instead of raising NoMethodError (#387).
- SearchOptions: `sort_order` without `sort_by` raises ArgumentError
  instead of being silently ignored, matching all other clients (#388).

Signed-off-by: Alex Le <alex.le@improving.com>
Signed-off-by: Alex Le <alex.le@improving.com>
@Aryex
Aryex force-pushed the agent/388/ft-search-builders branch from 80a002c to 3e1fc1f Compare October 30, 2026 15:45
Aryex added 2 commits October 30, 2026 08:55
Signed-off-by: Alex Le <35547559+Aryex@users.noreply.github.com>
@Aryex
Aryex marked this pull request as ready for review October 30, 2026 15:57

@jamesx-improving jamesx-improving 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.

LGTM

@Aryex
Aryex requested a review from yipin-chen October 30, 2026 17:26
@Aryex
Aryex merged commit 41a9955 into main Oct 30, 2026
20 checks passed
@Aryex
Aryex deleted the agent/388/ft-search-builders branch October 30, 2026 17:58
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.

Search Module: Reject sort_order when sort_by is omitted Search Module: Preserve explicit empty FT.CREATE stopword lists

3 participants