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

  1. Filter out empty/whitespace inputs and unsupported content parts before embedding
  2. Check input sizes against the model's token limits and truncate or chunk
  3. Retry once — transient empty-batch responses occur under load; capture request_id for tracing
  4. 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

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


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/7d11e00581b09a23. Report an issue: GitHub.