[BUG] Qdrant metadata content overwrites the indexed document body

Aperta
#9,129 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Ymmcc ci sta già lavorando.

Dal 5/11/2026.

  • #9130 di @Ymmcc — aperta

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
databases

Direzione di ricerca

Start at crewai/rag/qdrant/client.py and read _create_point_from_document, which the issue identifies as the shared payload helper for sync and async adds. The issue reports an open linked pull request (#9130) with regression tests already prepared. Done means the stored and returned document body remains the original text while non-conflicting metadata remains available.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description

Qdrant document metadata containing a content key silently replaces the document text in the stored payload. The embedding is computed from document["content"], but search returns metadata["content"] as the document body. Both add_documents and aadd_documents use the same payload helper.

Reproduction

Reproduced on main at 6bd60b223101a11f7ac675706ff1ebb03314c95d (CrewAI 1.15.35), Windows, Python 3.12.15, qdrant-client 1.14.3. No server, model, or API key is needed:

from crewai.rag.qdrant.client import QdrantClient
from qdrant_client import QdrantClient as SDKClient
from qdrant_client.models import Distance, VectorParams

sdk = SDKClient(location=":memory:")
try:
    client = QdrantClient(client=sdk, embedding_function=lambda text: [1.0, 0.0, 0.0])
    client.create_collection(
        collection_name="content_repro",
        vectors_config=VectorParams(size=3, distance=Distance.COSINE),
    )
    client.add_documents(collection_name="content_repro", documents=[{
        "content": "Original document text",
        "metadata": {"content": "Metadata text", "source": "example.txt"},
    }])
    result = client.search(collection_name="content_repro", query="Original document text")[0]
    print(result["content"])
    assert result["content"] == "Original document text", result
finally:
    sdk.close()

Actual: prints Metadata text and fails the assertion. The equivalent async create/add/search sequence returns the same wrong text.

Expected: the canonical document body remains Original document text. Non-conflicting metadata such as source remains available.

Cause and proposed fix

_create_point_from_document builds {"content": doc["content"], **metadata}, so metadata wins on collision. Assigning the reserved payload content field after expanding metadata preserves the document body. This keeps the existing flat payload layout and metadata filtering behavior; it does not introduce a new metadata storage format or recover previously overwritten content.

I checked existing issues and open PRs for this collision and did not find a duplicate. A one-line fix and regression tests for mapping/list metadata and empty/nonempty text are ready. The four new cases fail before the fix; the full Qdrant test module passes (47 tests) after it. Real in-memory sync/async roundtrips were also checked.

AI disclosure

AI-generated contribution: the investigation, reproduction, proposed implementation, tests, and this report were prepared and run with an AI coding assistant at the contributor's request. Please apply the required llm-generated label if my account cannot manage repository labels.

Lingua principale
Python
Stelle
60.6k
Fork
9.1k
Merge medio
1g 2h
PR unite (30g)
214

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di crewAIInc/crewAI

Tutte le issue di crewAIInc/crewAI

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.