GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(search): exclude MAX from SORTBY nargs in FT.AGGREGATE by wn1331 · Pull Request #3587 · redis/node-redis

Conversation

@wn1331

@wn1331 wn1331 commented Nov 6, 2026 •
edited by cursor Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Description

FT.AGGREGATE currently counts the optional MAX clause as part of SORTBY nargs. For example, sorting by one property with MAX produces SORTBY 3 @field MAX 2, so RediSearch treats MAX as another sort property and rejects the command with SEARCH_PARSE_ARGS MISSING ASC or DESC after sort field (MAX).

Count only the sort properties and optional directions, then append MAX after the counted arguments. This produces the server-expected form: SORTBY 1 @field MAX 2.

The regression coverage includes argument serialization with and without an explicit direction and an integration test that verifies both the limit and descending result order.

Validation

  • npm run build
  • npx eslint --max-warnings=0 packages/search/lib/commands/AGGREGATE.ts packages/search/lib/commands/AGGREGATE.spec.ts
  • npm run check:command-jsdoc
  • cd packages/search && npx mocha -r tsx --exit ./lib/**/*.spec.ts (327 passing)

The root npm test run was attempted locally but stalled in the Sentinel topology under macOS/Colima. The complete @redis/search suite passed against the repository Redis test image.


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • No documentation update is needed because this fixes command serialization without changing the API.

Note

Low Risk
Narrow command-encoding fix in FT.AGGREGATE SORTBY with no public API change; wrong wire format was already broken at runtime.

Overview
Fixes FT.AGGREGATE serialization when a SORTBY step includes MAX: the client was counting MAX in the SORTBY argument length, so RediSearch saw MAX as another sort field and failed parsing.

AGGREGATE.ts now calls pushVariadicWithLength on sort fields (and optional ASC/DESC) only, then appends MAX afterward—e.g. SORTBY 1 @by MAX 1 instead of SORTBY 3 @by MAX 1.

Tests update the unit expectation, add a multi-field + direction + MAX case, and add a live client test that SORTBY with DESC and MAX: 2 returns the top two values in order.

Reviewed by Cursor Bugbot for commit 6f557c6. Bugbot is set up for automated code reviews on this repo. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chatgpt-codex-connector[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@wn1331
fix(search): exclude MAX from SORTBY nargs in FT.AGGREGATE
6f557c6
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T02:04:15.159524Z 6f557c6 PR opened
ℹ️ 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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

nkaradzhov
nkaradzhov approved these changes Nov 6, 2026
View reviewed changes

@nkaradzhov nkaradzhov left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks, LGTM.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nkaradzhov
nkaradzhov merged commit 2df73c8 into redis:master Nov 6, 2026
15 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@nkaradzhov nkaradzhov nkaradzhov approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@wn1331 @nkaradzhov
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.