HKUDS/DeepTutor · error · ValueError
DashScope response parsed successfully but no embedding vect
Error message
DashScope response parsed successfully but no embedding vectors were returned.
What it means
_parse_response iterates returned embeddings, skips items lacking an embedding attribute, and raises ValueError if none survived — a 200 response with output present but zero usable vectors. The call succeeded at transport level yet produced no embeddings, which the adapter treats as a data error rather than returning an empty list.
Source
Thrown at deeptutor/services/embedding/adapters/dashscope_native.py:207
# `output` is dict-like in the SDK.
if isinstance(output, dict):
raw = output.get("embeddings") or []
else:
raw = getattr(output, "embeddings", None) or []
embeddings: List[List[float]] = []
for item in raw:
if isinstance(item, dict):
vec = item.get("embedding")
else:
vec = getattr(item, "embedding", None)
if vec is None:
continue
embeddings.append(list(vec))
if not embeddings:
raise ValueError(
"DashScope response parsed successfully but no embedding vectors were returned."
)
usage = getattr(resp, "usage", {}) or {}
if not isinstance(usage, dict):
usage = {
k: getattr(usage, k, None)
for k in ("input_tokens", "output_tokens", "total_tokens")
if hasattr(usage, k)
}
actual_dims = len(embeddings[0]) if embeddings else 0
logger.info(
f"Successfully generated {len(embeddings)} DashScope embeddings "
f"(model: {model_name}, dimensions: {actual_dims}, "
f"fusion={request.enable_fusion})"
)
View on GitHub (pinned to 3e82f13042)
Solutions
- Filter out empty/whitespace inputs and unsupported content parts before embedding
- Check input sizes against the model's token limits and truncate or chunk
- Retry once — transient empty-batch responses occur under load; capture request_id for tracing
- If reproducible with a single input, report that input (redacted) with request_id to DashScope
Example fix
# before
texts = ["", " ", t for t in raw_texts] # empties slip through
resp = await adapter.embed(EmbeddingRequest(texts=texts)) # ValueError
# after
texts = [t for t in raw_texts if t and t.strip()]
if texts:
resp = await adapter.embed(EmbeddingRequest(texts=texts)) Defensive patterns
Strategy: validation
Validate before calling
texts = [t for t in texts if t and t.strip()]
contents = [p for p in (contents or []) if p.get("kind") in ("text", "image") and p.get("value")]
if not texts and not contents:
raise ValueError("nothing to embed after filtering")
resp = await adapter.embed(EmbeddingRequest(texts=texts, contents=contents)) Try / catch
try:
return await adapter.embed(req)
except ValueError as e:
if "no embedding vectors" in str(e):
req = filter_empty_inputs(req)
if req is not None:
return await adapter.embed(req)
raise Prevention
- Never send empty/whitespace inputs to embedding APIs
- Chunk oversized inputs to the model's token limit
- Alert on zero-vector results — they usually indicate bad input data
When it happens
Trigger: DashScope returns output with an empty embeddings array, or items whose embedding field is None, while inputs were non-empty; reached via _embed_multimodal/_embed_text.
Common situations: Empty-string inputs filtered out server-side; content parts the model silently refuses to embed; input-size/truncation edge cases; client-side input filtering causing count mismatch.
Related errors
- DashScope response missing `output` (request_id={getattr(res
- dashscope SDK not installed. Run `pip install dashscope` (or
- DashScope MultiModalEmbedding call failed: status={status_co
- Archive '{sanitized_filename}' contained no supported files.
- Cohere v1 API does not support multimodal `contents`. Use em
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/7d11e00581b09a23.
Report an issue: GitHub.