Skip to content

fix(redis): accept inferred client types in SearchIndex; reject RESP=3#29

Merged
booleanhunter merged 1 commit into
mainfrom
feat/redis-client-resp2-guard
May 20, 2026
Merged

fix(redis): accept inferred client types in SearchIndex; reject RESP=3#29
booleanhunter merged 1 commit into
mainfrom
feat/redis-client-resp2-guard

Conversation

@booleanhunter
Copy link
Copy Markdown
Member

@booleanhunter booleanhunter commented May 16, 2026

Issue:
Calling new SearchIndex(schema, client) previously had TS complaining when client came directly from createClient or createCluster without an explicit type annotation.

The inferred client's RESP generic resolved to the 2 | 3 union, which forces callers to manually pin RESP: 2 by doing createClient({ ..., RESP: 2 }) to satisfy TypeScript.

Fix:

  • new SearchIndex(schema, client) now compiles when client is the inferred return of createClient/createCluster, with no explicit type annotation required at the call site.
  • throw a RedisVLError at SearchIndex construction for Clients configured with RESP: 3
  • Add unit tests for the protocol guard and the RESP=3 rejection

@booleanhunter booleanhunter force-pushed the feat/redis-client-resp2-guard branch 2 times, most recently from 06ecd34 to 9633c3b Compare May 16, 2026 10:51
@booleanhunter booleanhunter marked this pull request as draft May 16, 2026 10:56
@booleanhunter booleanhunter marked this pull request as ready for review May 16, 2026 10:56
ajGingrich added a commit that referenced this pull request May 18, 2026
RESP=3 is rejected at SearchIndex construction (see PR #29), so the
Map-row branch in aggregate() is purely about the RESP=2 Map type-
mapping opt-in, not about RESP3.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Issue:
Calling new SearchIndex(schema, client) previously failed to compile
when client came directly from createClient or createCluster without
an explicit type annotation.

The inferred client's RESP generic resolved to the 2 | 3 union,
which forces callers to manually pin RESP: 2 by doing createClient({ ..., RESP: 2 })
to satisfy TypeScript.

Fix:

- new SearchIndex(schema, client) now compiles when client is the
inferred return of createClient/createCluster, with no explicit
type annotation required at the call site.
- throw a RedisVLError at SearchIndex construction for Clients configured with RESP: 3
- Add unit tests for the protocol guard and the RESP=3 rejection
@booleanhunter booleanhunter force-pushed the feat/redis-client-resp2-guard branch from 9633c3b to ee52eb4 Compare May 20, 2026 19:36
@booleanhunter booleanhunter merged commit f1f636c into main May 20, 2026
9 checks passed
@booleanhunter booleanhunter deleted the feat/redis-client-resp2-guard branch May 20, 2026 19:41
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.

1 participant