embed() returns [] when all inputs are empty or whitespace-only (embedder.py:44-46).
embed_query() subscripts the result with [0] unconditionally, so a blank query raises a bare
IndexError rather than a meaningful error. The batch path already handles empty inputs correctly
by substituting zero vectors — only the single-query wrapper is affected.
Location: devrag/ingest/embedder.py:81-83
Suggested fix:
Decide the intended contract and make it explicit. Either reject blank queries with a clear error:
def embed_query(self, text: str) -> list[float]:
if not text.strip():
raise ValueError("embed_query() requires non-empty text")
return self.embed([text])[0]
or mirror the batch path's zero-vector behavior for consistency:
def embed_query(self, text: str) -> list[float]:
result = self.embed([text])
return result[0] if result else [0.0] * self.dim
The first is preferable if a blank query indicates a caller bug worth surfacing; the second if
blank queries are expected input that should degrade quietly. Whichever is chosen, callers of
embed_query() should be checked for their assumption about the return value.
Source: Surfaced by /engineer-agent audit-code (June run); re-verified by hand against HEAD d97b2eb on 2026-07-15, confidence high.
embed()returns[]when all inputs are empty or whitespace-only (embedder.py:44-46).embed_query()subscripts the result with[0]unconditionally, so a blank query raises a bareIndexErrorrather than a meaningful error. The batch path already handles empty inputs correctlyby substituting zero vectors — only the single-query wrapper is affected.
Location:
devrag/ingest/embedder.py:81-83Suggested fix:
Decide the intended contract and make it explicit. Either reject blank queries with a clear error:
or mirror the batch path's zero-vector behavior for consistency:
The first is preferable if a blank query indicates a caller bug worth surfacing; the second if
blank queries are expected input that should degrade quietly. Whichever is chosen, callers of
embed_query()should be checked for their assumption about the return value.Source: Surfaced by
/engineer-agent audit-code(June run); re-verified by hand against HEADd97b2ebon 2026-07-15, confidence high.