Skip to content

fix(search): allow LOAD * in FT.AGGREGATE #2726#3241

Merged
nkaradzhov merged 1 commit intoredis:masterfrom
watersRand:fix/ft.Aggregate_load
Apr 22, 2026
Merged

fix(search): allow LOAD * in FT.AGGREGATE #2726#3241
nkaradzhov merged 1 commit intoredis:masterfrom
watersRand:fix/ft.Aggregate_load

Conversation

@watersRand
Copy link
Copy Markdown
Contributor

@watersRand watersRand commented Apr 19, 2026

Description

This pull request adds support for the LOAD * syntax within the FT.AGGREGATE command.

Purpose:
According to the [RediSearch documentation](https://redis.io/commands/ft.aggregate/), the LOAD clause typically expects a specific number of arguments (nargs). However, it also supports a wildcard * to project all document attributes into the aggregation pipeline.

Problem:
The previous implementation utilized pushVariadicWithLength, which automatically prepended a numeric count to the arguments. When passing *, the library generated LOAD 1 *, resulting in a Redis protocol error.

Solution:
The parseAggregateOptions function now includes type narrowing to handle the wildcard case:

  • If LOAD is exactly '*', the parser pushes the literal string * as the argument count substitute.
  • For all other cases (individual strings, objects, or arrays of fields), the original pushVariadicWithLength logic is maintained to ensure backward compatibility.

Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

Note

Medium Risk
Changes FT.AGGREGATE argument construction to special-case LOAD, which can affect query serialization and compatibility with RediSearch. While covered by a new unit test, this touches core command parsing logic used broadly by clients.

Overview
Adds LOAD * support for FT.AGGREGATE. FtAggregateOptions.LOAD now accepts the wildcard '*', and parseAggregateOptions emits LOAD * directly instead of LOAD 1 * (while keeping the existing counted-args behavior for specific fields/aliases and arrays).

Updates tests to cover the new wildcard projection case.

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

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 095ae1c. Configure here.

if (options?.TIMEOUT !== undefined) {
parser.pushVariadicWithLength(args);
}
} if (options?.TIMEOUT !== undefined) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing newline causes } if on same line

Low Severity

The closing brace of the LOAD block and the TIMEOUT if statement are on the same line (} if (), making it visually ambiguous whether this is an independent if or was intended to be an else if. The original code had these as clearly separated independent if blocks with a blank line between them. A future maintainer could easily mistake this for a missing else and introduce a regression.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 095ae1c. Configure here.

Copy link
Copy Markdown
Collaborator

@nkaradzhov nkaradzhov left a comment

Choose a reason for hiding this comment

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

@watersRand Thanks, this looks good!

@nkaradzhov nkaradzhov merged commit f6e57ce into redis:master Apr 22, 2026
16 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