Skip to content

RedisVectorStore broken against real RediSearch (binary-field decode, reconnect persistence) — hidden by MagicMock #831

Closed

Description

@AmitoVrito

Summary

RedisVectorStore (src/synapsekit/retrieval/redis_vector.py) never ran against a real RediSearch — its only test used MagicMock, which hid two bugs. Found while converting to real testcontainers tests (epic #829).

Bugs

  1. UnicodeDecodeError on search — FT.SEARCH was issued without a RETURN clause, so RediSearch also returns the raw FLOAT32 embedding bytes. The result parser then calls .decode() on every field value, crashing on the binary embedding ('utf-8' codec can't decode byte 0xcd). Any real search raised.
  2. No reconnect persistence — search() short-circuited on self._dim is None, so a freshly reconnected instance (which hasn't run add() and has no cached dim) returned [] even when the index and vectors already exist in Redis.

Fix

  • Add RETURN 3 text metadata score to FT.SEARCH so only parsed fields come back.
  • Drop the self._dim is None guard; _search_sync returns [] on ResponseError (index genuinely absent), which also correctly handles search-before-add.

Test

Real redis/redis-stack testcontainer: nearest-neighbour ranking (cosine distance ascending), metadata filter, top_k, persistence across reconnect, empty/negative cases. Replaces the MagicMock test. Runs in the CI integration job.

Part of epic #829.

Activity

  1. added this to the v2.0.1 milestone on Jul 21, 2026
  2. added
    bug
    retrieval
    v2.0.1
    on Jul 21, 2026
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

    bugretrievalv2.0.1

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions