[8.8] [MOD-19620] Fix crash on malformed distributed LOAD AS clause by redisearch-backport-pull-request[bot] · Pull Request #11951 · RediSearch/RediSearch · GitHub
Skip to content

[8.8] [MOD-19620] Fix crash on malformed distributed LOAD AS clause - #11951

Closed
redisearch-backport-pull-request[bot] wants to merge 3 commits into
8.8from
backport-agent/pr-11702-to-8.8
Closed

redisearch-backport-pull-request[bot] wants to merge 3 commits into
8.8from
backport-agent/pr-11702-to-8.8

Conversation

@redisearch-backport-pull-request

@redisearch-backport-pull-request redisearch-backport-pull-request Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #11702 to 8.8.

Drift from original

Compared line by line against 9a8479009. Product code is identical.

  • tests/cpptests/coord_tests/test_cpp_distribute_load.cpp, forced by the 8.8 API: AREQ_New() + AREQ_Compile(r, ctx, rmArgs, n, false, qerr) and AREQ_DecrRef instead of master's signatures and AREQ_Free; dropped AREQ_AddRequestFlags(r, QEXEC_F_IS_COORDINATOR) (the flag doesn't exist on 8.8, and the test calls AGGPLN_Distribute directly).
  • Extra file, tests/pytests/test_blocked_client_timeout.py (branch-only test, not on master): test_fail_timeout_before_execution_plan_error used LOAD 2 @name AS to get an error raised late, at pipeline construction. The backported fix rejects that at parse time, so the test now uses LOAD 3 @name AS AS ("Alias for LOAD cannot be AS"), which still passes parsing and fails at pipeline construction. Test intent unchanged.
  • Include-block conflict in src/aggregate/aggregate_plan.c: kept the branch's includes; the lines added are identical to master.

Original PR

Cherry-pick result

  • Resolved 2 conflict(s) — see Conflict Log below.

Conflict Log

src/aggregate/aggregate_plan.c

  • Conflict: The new query_error.h and spec.h includes conflict with the release branch include block.
  • Why it conflicted: The release branch predates master's include-what-you-use cleanup (include-what-you-use #8895), which replaced the reducer, expression, array and ctype includes.
  • Resolution: Retained the release branch includes and added only query_error.h and spec.h. Kept the shared LOAD validation and all other original changes.
  • Rationale: Provides the validator dependencies without importing an unrelated include refactor; preserves rejection of dangling AS before distributed planning.

tests/cpptests/coord_tests/test_cpp_distribute_load.cpp

  • Conflict: The new test file applies textually, but uses master request APIs unavailable on this release branch.
  • Why it conflicted: The branch predates the request argv ownership API change ([MOD-17409] Hold the command argv on requests; strictly parse numeric command arguments #10699) and has different request compilation, cleanup and/or lookup interfaces.
  • Resolution: Used AREQ_New() and AREQ_Compile(r, ctx, rmArgs, rmArgs.size(), false, qerr). Used AREQ_DecrRef for request cleanup, matching the release branch reference-counted lifecycle.
  • Rationale: Exercises the same malformed LOAD and field-named-AS cases using existing release APIs. Checked against branch declarations and existing code; builds and tests were intentionally not run and CI must verify.

Release notes

  • This PR requires release notes
  • This PR does not require release notes

🤖 Generated by the auto-backport workflow.

* Fix malformed distributed LOAD AS handling

* Reject LOAD clauses with a dangling AS while parsing, and add tests

The distributed planner walks a LOAD step's raw argument slice and assumed
any `AS` was followed by an alias, citing validation that ran earlier. No
earlier check existed: both LOAD parsers (FT.AGGREGATE and FT.HYBRID) only
slice a counted number of tokens, and on a coordinator the planner runs
before the pipeline validates the step. So `LOAD 2 @field AS` read past the
end of the slice.

The planner also over-read on valid input: it generates its own LOAD step
from a FILTER expression's field names, so `FILTER "@x == 1 || @as == 1"`
produced a slice ending in a plain field named `AS`.

Add the missing check to both LOAD parsers via a shared
PLNLoadStep_ValidateArgs, reusing the pipeline's existing error message. In
the planner, treat `AS` as alias syntax only when a token follows it, which
covers the generated steps and replaces the earlier break-on-end guard.

Tests: a coordinator cpptest suite drives both triggers through AREQ_Compile
and AGGPLN_Distribute, a FT.HYBRID parse case pins the hybrid rejection, and
testAggregateBadLoadArgs checks the end-to-end error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Apply suggestion from @Itzikvaknin

Co-authored-by: Itzikvaknin <82322982+Itzikvaknin@users.noreply.github.com>

* Remove unnecessary comments in dist_plan.cpp

Remove comments explaining alias handling in ArgsCursor processing.

* Remove comments from PLNLoadStep_ValidateArgs

Removed comments explaining the argument validation process.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Itzikvaknin <82322982+Itzikvaknin@users.noreply.github.com>
(cherry picked from commit 9a84790)
@redisearch-backport-pull-request redisearch-backport-pull-request Bot added size:M codex aardvark auto-backport This PR was automatically backported by an agent auto-backport-conflicts There were conflicts in this automatic backport labels Oct 20, 2026
@ofiryanai
ofiryanai requested review from ofiryanai and removed request for eyalrund October 20, 2026 14:44
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

@ofiryanai

Copy link
Copy Markdown
Collaborator

/backport-fix Keep everything identical to master commit 9a84790; product code is already faithful, change only the listed test files. In tests/cpptests/coord_tests/test_cpp_distribute_load.cpp: QEXEC_F_IS_COORDINATOR does not exist on 8.8 (compile error at :57). Drop that line; the tests call AGGPLN_Distribute directly. RLOOKUP_FOREACH exists on 8.8, keep it as in master. Change nothing else.

@redisearch-backport-pull-request

Copy link
Copy Markdown
Contributor Author

🤖 Auto-backport fix declined

What I observed: Failed CI run 39441669242 was reported: https://github.com/RediSearch/RediSearch/actions/runs/39441669242. No log excerpts were provided.
Specific obstacle: The failed-step logs are unavailable, and this environment has no network or token to recover them. The reviewer hint cannot substitute for the required failure evidence.
What the reviewer needs to decide: Provide failed-step log excerpts for this run and rerun the backport fix workflow.

Failed run: https://github.com/RediSearch/RediSearch/actions/runs/39441669242

ofiryanai and others added 2 commits October 21, 2026 11:22
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ofiryanai ofiryanai changed the title [8.8] Fix crash on malformed distributed LOAD AS clause [8.8] [MOD-19620] Fix crash on malformed distributed LOAD AS clause Oct 21, 2026
@sonarqubecloud

Copy link
Copy Markdown

@ofiryanai ofiryanai closed this Oct 21, 2026
auto-merge was automatically disabled October 21, 2026 15:57

Pull request was closed

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

Labels

aardvark auto-backport This PR was automatically backported by an agent auto-backport-conflicts There were conflicts in this automatic backport codex size:M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants