{"record":{"id":"85f6a52c86e90582","repo":"MemPalace/mempalace","slug":"embedding-api-at-self-url-returned-no-data-ar","errorCode":null,"errorMessage":"Embedding API at {self._url} returned no 'data' array: {data.get('error', data)}","messagePattern":"Embedding API at (.+?) returned no 'data' array: (.+?)","errorType":"exception","errorClass":"EmbeddingAPIError","httpStatus":null,"severity":"error","filePath":"mempalace/embedding.py","lineNumber":585,"sourceCode":"        \"\"\"Validate one ``/v1/embeddings`` response and return L2-normed vectors.\n\n        Guards every way a non-conformant server could corrupt the store\n        silently: a missing/short ``data`` array, response ``index`` values\n        that aren't the contiguous ``0..n-1`` batch positions (sorting then\n        zipping positionally would otherwise misalign vectors with texts), and\n        malformed / ragged / base64 embedding payloads. All failures raise\n        :class:`EmbeddingAPIError` naming the endpoint rather than a cryptic\n        numpy error — a silent wrong result would break the 100%-recall promise.\n        \"\"\"\n        import numpy as np\n\n        if not isinstance(data, dict):\n            raise EmbeddingAPIError(\n                f\"Embedding API at {self._url} returned a non-object response: {data}\"\n            )\n        rows = data.get(\"data\")\n        if not isinstance(rows, list):\n            raise EmbeddingAPIError(\n                f\"Embedding API at {self._url} returned no 'data' array: {data.get('error', data)}\"\n            )\n        if len(rows) != n:\n            raise EmbeddingAPIError(\n                f\"Embedding API at {self._url} returned {len(rows)} embeddings for {n} inputs\"\n            )\n        # The endpoint may return rows out of order — sort by index, then\n        # require the indices to be exactly 0..n-1 so positional alignment is\n        # provably correct (a server using absolute or duplicate indices would\n        # otherwise pass the count check yet map vectors to the wrong texts).\n        try:\n            rows = sorted(rows, key=lambda d: d.get(\"index\", -1))\n            indices = [r.get(\"index\") for r in rows]\n        except AttributeError as e:\n            raise EmbeddingAPIError(\n                f\"Embedding API at {self._url} returned non-object rows: {e}\"\n            ) from e\n        if indices != list(range(n)):","sourceCodeStart":567,"sourceCodeEnd":603,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/embedding.py#L567-L603","documentation":"Raised by _vectors_from_response when the response object has no 'data' key or 'data' is not a list. The message prefers data.get('error', data) so that if the server replied with an OpenAI-style error object (e.g. {\"error\": {\"message\": ...}}), the actual server error text is surfaced instead of the raw payload skeleton — turning a validation failure into a diagnostic.","triggerScenarios":"The endpoint returned an application-level error in a 200 body: wrong model name ({\"error\": {\"message\": \"model not found\"}}), auth failures from gateways, or a server that returns {\"object\": \"list\"} with data under a different key. Also any non-conformant server whose response omits 'data'.","commonSituations":"embedding_api_model set to a model the server does not host; expired API key on a relay; LM Studio with the embeddings model not loaded; server returns key 'embeddings' instead of 'data'.","solutions":["Read the error field in the message — it usually contains the server's own complaint (bad model name, auth, etc.) and fix that","Verify embedding_api_model matches a model the server actually serves (curl the /v1/models endpoint)","Ensure the embeddings model is loaded in LM Studio / vLLM / Ollama before ingest","Confirm the endpoint path ends in /v1/embeddings, not /v1 or /embeddings-only variants"],"exampleFix":"# before\n{\"embedding_api_model\": \"text-embedding-3-large\"}  # server doesn't host it\n# after (local LM Studio example)\n{\"embedding_api_model\": \"text-embedding-nomic-embed-text-v1.5\"}","handlingStrategy":"validation","validationCode":"resp = probe(url, model, inputs=[\"a\"])\nassert isinstance(resp, dict) and isinstance(resp.get(\"data\"), list), resp.get(\"error\", resp)","typeGuard":"def has_data_array(data) -> bool:\n    return isinstance(data, dict) and isinstance(data.get(\"data\"), list)","tryCatchPattern":"try:\n    vecs = ef(texts)\nexcept EmbeddingAPIError as e:\n    if \"no 'data' array\" in str(e):\n        # the embedded server error text is in the message; surface it to the user\n        show_config_error(e)","preventionTips":["Verify embedding_api_model against the server's /v1/models list before ingest","Load the embeddings model in LM Studio/vLLM/Ollama before starting mempalace","Probe the endpoint once at pipeline start rather than discovering errors mid-ingest"],"tags":["embedding","api","validation","model-config"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}