{"record":{"id":"21c26c3b3cfaa329","repo":"openai/openai-python","slug":"no-embedding-data-received","errorCode":null,"errorMessage":"No embedding data received","messagePattern":"No embedding data received","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/lib/_parsing/_embeddings.py","lineNumber":21,"sourceCode":"import array\nimport base64\nfrom typing import cast\n\nfrom ..._types import Omit, NotGiven\nfrom ..._utils import is_given\nfrom ..._extras import numpy as np, has_numpy\nfrom ...types.create_embedding_response import CreateEmbeddingResponse\n\n\ndef parse_embedding_response(\n    obj: CreateEmbeddingResponse, *, encoding_format: str | Omit | NotGiven\n) -> CreateEmbeddingResponse:\n    if is_given(encoding_format):\n        # don't modify the response object if a user explicitly asked for a format\n        return obj\n\n    if not obj.data:\n        raise ValueError(\"No embedding data received\")\n\n    for embedding in obj.data:\n        data = cast(object, embedding.embedding)\n        if not isinstance(data, str):\n            continue\n        if not has_numpy():\n            # use array for base64 optimisation\n            embedding.embedding = array.array(\"f\", base64.b64decode(data)).tolist()\n        else:\n            embedding.embedding = np.frombuffer(  # type: ignore[no-untyped-call]\n                base64.b64decode(data), dtype=\"float32\"\n            ).tolist()\n\n    return obj\n","sourceCodeStart":3,"sourceCodeEnd":36,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/lib/_parsing/_embeddings.py#L3-L36","documentation":"parse_embedding_response decodes base64 embeddings into numpy float arrays when no explicit encoding_format was requested. If the API response contains an empty data list, there is nothing to decode and it raises ValueError('No embedding data received').","triggerScenarios":"A CreateEmbeddingResponse arrives with data == [] (or the mock/response object has no data) and encoding_format was not given, when using the embeddings parsing helper.","commonSituations":"Mocking responses without data; a malformed or truncated API response; proxy/gateway stripping the body.","solutions":["Inspect the raw response before parsing (check len(response.data))","Retry the embeddings.create call — an empty body is usually transient or a proxy issue","If you requested base64 explicitly, pass encoding_format='base64' so the helper returns the response untouched"],"exampleFix":"# before\nparsed = parse_embedding_response(response, encoding_format=NOT_GIVEN)\n# after\nif not response.data:\n    raise ValueError(\"empty embedding response from API\")\nparsed = parse_embedding_response(response, encoding_format=NOT_GIVEN)","handlingStrategy":"validation","validationCode":"if not response.data:\n    raise ValueError(\"empty embedding response; retrying\")","typeGuard":null,"tryCatchPattern":"try:\n    parsed = parse_embedding_response(response, encoding_format=NOT_GIVEN)\nexcept ValueError as e:\n    if \"No embedding data\" in str(e):\n        response = client.embeddings.create(...)  # retry\n    else:\n        raise","preventionTips":["Check response.data before parsing","Pass encoding_format explicitly to bypass decoding"],"tags":["embeddings","parsing","empty-response"],"backgroundTag":"empty-api-response","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}