Skip to content

MilvusVectorStore broken against real Milvus (no primary key, IndexParams misuse, metadata lost, event-loop block) — hidden by MagicMock #840

Closed

Description

@AmitoVrito

Summary

MilvusVectorStore (src/synapsekit/retrieval/milvus.py), previously only MagicMock-tested, was broken against a real Milvus. Found via real Milvus Lite (embedded real engine) tests (epic #829).

Bugs (all hidden by the mock)

  1. Schema has no primary key — _ensure_collection adds text + embedding but no primary field (the comment claimed auto_id means "do NOT add a manual primary field"). Milvus requires an explicit PK even with auto_id → PrimaryKeyException: Schema must have a primary key field. Every add/search failed.
  2. create_index gets a dict, not IndexParams — MilvusClient.create_index requires an IndexParams object built via prepare_index_params().add_index(...); passing the raw dict raises ParamError.
  3. Metadata never returned — stored as dynamic fields with output_fields=["text"], so search results carried no metadata (dynamic fields aren't returned unless named).
  4. Blocks the event loop — add/search call the synchronous MilvusClient directly inside async def.

Fix

  • Declare an auto-id INT64 primary key; store metadata in a JSON field (queried via metadata["key"] == ... and returned via output_fields=["text","metadata"]).
  • Build IndexParams with prepare_index_params().add_index(...).
  • Offload all client calls via asyncio.to_thread.

Test

Real Milvus Lite (the official embedded engine — standalone needs etcd+minio): true nearest-neighbour ranking, metadata filter, top_k, persistence across reopen, empty/negative, async contract. First-ever test for this store; runs in the CI integration job (with milvus-lite declared).

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