{"record":{"id":"7d11e00581b09a23","repo":"HKUDS/DeepTutor","slug":"dashscope-response-parsed-successfully-but-no-embe","errorCode":null,"errorMessage":"DashScope response parsed successfully but no embedding vectors were returned.","messagePattern":"DashScope response parsed successfully but no embedding vectors were returned\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"deeptutor/services/embedding/adapters/dashscope_native.py","lineNumber":207,"sourceCode":"\n        # `output` is dict-like in the SDK.\n        if isinstance(output, dict):\n            raw = output.get(\"embeddings\") or []\n        else:\n            raw = getattr(output, \"embeddings\", None) or []\n\n        embeddings: List[List[float]] = []\n        for item in raw:\n            if isinstance(item, dict):\n                vec = item.get(\"embedding\")\n            else:\n                vec = getattr(item, \"embedding\", None)\n            if vec is None:\n                continue\n            embeddings.append(list(vec))\n\n        if not embeddings:\n            raise ValueError(\n                \"DashScope response parsed successfully but no embedding vectors were returned.\"\n            )\n\n        usage = getattr(resp, \"usage\", {}) or {}\n        if not isinstance(usage, dict):\n            usage = {\n                k: getattr(usage, k, None)\n                for k in (\"input_tokens\", \"output_tokens\", \"total_tokens\")\n                if hasattr(usage, k)\n            }\n\n        actual_dims = len(embeddings[0]) if embeddings else 0\n        logger.info(\n            f\"Successfully generated {len(embeddings)} DashScope embeddings \"\n            f\"(model: {model_name}, dimensions: {actual_dims}, \"\n            f\"fusion={request.enable_fusion})\"\n        )\n","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/embedding/adapters/dashscope_native.py#L189-L225","documentation":"_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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\ntexts = [\"\", \"   \", t for t in raw_texts]  # empties slip through\nresp = await adapter.embed(EmbeddingRequest(texts=texts))  # ValueError\n# after\ntexts = [t for t in raw_texts if t and t.strip()]\nif texts:\n    resp = await adapter.embed(EmbeddingRequest(texts=texts))","handlingStrategy":"validation","validationCode":"texts = [t for t in texts if t and t.strip()]\ncontents = [p for p in (contents or []) if p.get(\"kind\") in (\"text\", \"image\") and p.get(\"value\")]\nif not texts and not contents:\n    raise ValueError(\"nothing to embed after filtering\")\nresp = await adapter.embed(EmbeddingRequest(texts=texts, contents=contents))","typeGuard":null,"tryCatchPattern":"try:\n    return await adapter.embed(req)\nexcept ValueError as e:\n    if \"no embedding vectors\" in str(e):\n        req = filter_empty_inputs(req)\n        if req is not None:\n            return await adapter.embed(req)\n    raise","preventionTips":["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"],"tags":["dashscope","response-parsing","embeddings","empty-result"],"backgroundTag":"empty-api-response","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}