Skip to content

WeaviateVectorStore broken against real Weaviate (v4 insert/search API, event-loop block, no collection create) — hidden by MagicMock #838

Closed

Description

@AmitoVrito

Summary

WeaviateVectorStore (src/synapsekit/retrieval/weaviate.py), previously only MagicMock-tested, is broken end-to-end against a real Weaviate (v4 client). Found via a real weaviate testcontainer (epic #829).

Bugs (all hidden by the mock)

  1. Blocks the event loop — add/search call the synchronous weaviate v4 client (insert_many, near_vector, aggregate, collections.*) directly inside async def, with no to_thread.
  2. insert_many API misuse — calls insert_many(data_objects=..., vectors=...); v4 takes a list of DataObject(properties=, vector=) and has no vectors= kwarg, so vectors are never attached → vector search can't work.
  3. Collection never created — collections.get(name) in v4 returns a handle without raising for a missing collection, so the try/except never calls create; should use collections.exists(name).
  4. return_metadata=["distance", "score"] — v4 expects MetadataQuery(distance=True), not a list of strings.
  5. Score always 0 — near_vector results have no score (that's for bm25/hybrid); obj.metadata.score is None → every result scores 0.0. Should derive from distance.
  6. Metadata dropped + filter broken — return_properties=["content"] returns only content, so obj.properties has no metadata; the Python metadata_filter then never matches.
  7. v4 connection missing gRPC — connect_to_custom is called without grpc_host/grpc_port, which v4 requires.
  8. No len(metadata) == len(texts) validation.

Fix

Offload via asyncio.to_thread; insert DataObject(properties, vector); use collections.exists; MetadataQuery(distance=True) with score = 1 - distance; return all properties and apply a native Filter; add gRPC defaults to connect_to_custom; validate metadata length.

Test

Real weaviate testcontainer (http + gRPC): true nearest-neighbour ranking, metadata filter, top_k, reconnect persistence, empty/negative, async contract. 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