You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(pipeline): re-upload of identical content unconditionally re-embeds all chunks, burning API credits and creating section gap #278
When the same content is re-uploaded (content hash matches existing document), the pipeline reuses the doc_id but does not short-circuit. It re-parses, re-TOC-extracts, re-chunks, re-embeds all chunks (burning OpenAI API credits), and calls upsert_document_and_replace_sections which deletes and re-inserts all section rows — creating a brief window where the document has zero sections and routing queries return empty results.
Root Cause
ingestion/pipeline.py around line 437–480:
existing=awaitfind_doc_id_by_hash(content_hash) # finds existing docdoc_id=existing.doc_id# reuse ID# No short-circuit — pipeline continues:parsed=awaitparse_document(data) # full PDF parsetoc=awaitextract_toc(parsed) # full TOC extractionsections=derive_sections(toc, parsed) # full section derivationchunks=chunk_sections(sections) # full chunkingvectors=embedder.embed([c.textforcinchunks]) # ← full API call, full costawaitsection_store.upsert_document_and_replace_sections(...) # ← DELETE + re-INSERT gapawaitvector_store.upsert_points(...) # full Qdrant upsert
Failure Scenario
Tenant uploads a 300-page PDF (1,500 chunks). Fully indexed. Cost: $0.15 in OpenAI embedding fees.
Tenant re-uploads the same PDF (accidentally, or from a sync).
Pipeline re-embeds all 1,500 chunks: another $0.15 wasted.
replace_sections deletes 50 section rows and re-inserts them. During the DELETE:
A concurrent routing query sees 0 sections → returns empty results.
High-traffic systems with periodic re-uploads accumulate significant wasted API costs.
Activity
piyushmakhija28 commentedon Jun 21, 2026
Fixed in PR #280 (Sprint R3/R4: fix(sprint-r3): root-cause fixes for all 39 bugs from code review round 3 + Sprint R4 round 4)