Skip to content

sync_to_async_redis fails for TLS clients configured with keywords #789

Closed

Description

@vishal-bala

RedisConnectionFactory.sync_to_async_redis can't convert a sync client configured with TLS keywords, so the async methods of SemanticCache (and anything else that converts a caller's client) fail on their first command. The same client works on every sync path.

Reproduction

Measured on main with redis-py 8.1.0. No server is needed, because the failure happens when the async pool builds its first connection:

import redis
from redisvl.redis.connection import RedisConnectionFactory

client = redis.Redis(host="example.com", ssl=True, password="x")
async_client = RedisConnectionFactory.sync_to_async_redis(client)
async_client.connection_pool.make_connection()
# TypeError: AbstractConnection.__init__() got an unexpected keyword argument 'ssl_validate_ocsp_stapled'

Through the public API, this is what a user sees from await cache.acheck(...) on a SemanticCache built with redis_client=Redis(ssl=True, ...).

A client built from a URL, Redis.from_url("rediss://..."), converts correctly and keeps TLS, so only keyword-configured TLS clients are affected.

Cause

sync_to_async_redis (redisvl/redis/connection.py) passes the sync pool's connection_kwargs through unchanged to AsyncConnectionPool. The sync SSLConnection carries keyword arguments that the async connection classes don't accept, so the first make_connection() raises.

The same pass-through breaks two other client shapes in the same way:

Sync client Error on first async command
Redis(ssl=True, ...) TypeError: ... unexpected keyword argument 'ssl_validate_ocsp_stapled'
Redis(unix_socket_path=...) TypeError: ... unexpected keyword argument 'path'
Sentinel(...).master_for(...) TypeError: ... unexpected keyword argument 'connection_pool'

The helper also picks the async TLS class with connection_class == SSLConnection, an exact-type check. A custom subclass of SSLConnection therefore gets a plaintext async connection, with the password still set.

Where it surfaces

  • BaseCache._get_async_redis_client (redisvl/extensions/cache/base.py) converts a provided client for all async cache methods.
  • AsyncSearchIndex's wrong-client error message tells users to call sync_to_async_redis() themselves.
  • feat(router): add async aroute and aroute_many to SemanticRouter #784 adds async routing to SemanticRouter through the same helper.

Suggested fix

Build the async connection from the sync pool's settings, not its raw kwargs: drop or translate the sync-only keys, map UnixDomainSocketConnection and SSLConnection (with issubclass) to their async equivalents, and raise a clear ValueError for Sentinel-managed pools, as the helper already does for RedisCluster.

Activity

  1. added
    bugSomething isn't working
    cachecache interface related
    on Oct 27, 2026
  2. added theissue type on Oct 30, 2026
  3. added a commit that references this issue on Nov 2, 2026
    c5070c6
  4. added a commit that references this issue on Nov 5, 2026
    59d36e1
  5. applied-ai-release-bot commented on Nov 6, 2026

    @applied-ai-release-bot

    🚀 Issue was released in v0.31.0 🚀

  6. applied-ai-release-bot commented on Nov 6, 2026

    @applied-ai-release-bot

    🚀 Issue was released in v0.31.0 🚀

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcachecache interface relatedreleasedThis issue/pull request has been released.

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions