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(embedder): BgeM3Embedder crashes with KeyError on 'dense_vecs' when FlagEmbedding returns unexpected shape #245
BgeM3Embedder.embed() accesses result['dense_vecs'] with a bare dict key lookup. If the installed FlagEmbedding library returns a different key name (e.g. 'dense' or 'embeddings') or if the model is loaded without dense-output support, a KeyError propagates uncaught. Because KeyError is not in _PRIMARY_UNAVAILABILITY_ERRORS, it bypasses the fallback logic and kills the ingest worker with a non-retriable 500.
Root Cause
ingestion/embedder.py around line 201:
result=self._flag_model.encode(texts, return_dense=True)
returnlist(result['dense_vecs']) # ← bare key lookup, no .get() or KeyError handling
KeyError is excluded from the fallback chain by design (it is not an infrastructure failure), so the exception propagates all the way to the HTTP layer as a 500.
Failure Scenario
FlagEmbedding library is updated to rename the key from dense_vecs to dense.
Worker calls BgeM3Embedder.embed([...]).
result['dense_vecs'] → KeyError: 'dense_vecs'.
No fallback is attempted. The ingest request returns 500.
Every ingest fails until the embedder code is patched.
Also triggered when BgeM3 is configured with return_dense=False or when the model variant only supports sparse encoding.
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)