{"record":{"id":"e9d842510a6d10ed","repo":"openai/openai-python","slug":"unexpected-list-delta-entry-is-not-a-dictionary-e9d842","errorCode":null,"errorMessage":"Unexpected list delta entry is not a dictionary: {delta_entry}","messagePattern":"Unexpected list delta entry is not a dictionary: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/openai/lib/streaming/_deltas.py","lineNumber":42,"sourceCode":"            acc[key] = delta_value\n            continue\n\n        if isinstance(acc_value, str) and isinstance(delta_value, str):\n            acc_value += delta_value\n        elif isinstance(acc_value, (int, float)) and isinstance(delta_value, (int, float)):\n            acc_value += delta_value\n        elif is_dict(acc_value) and is_dict(delta_value):\n            acc_value = accumulate_delta(acc_value, delta_value)\n        elif is_list(acc_value) and is_list(delta_value):\n            # for lists of non-dictionary items we'll only ever get new entries\n            # in the array, existing entries will never be changed\n            if all(isinstance(x, (str, int, float)) for x in acc_value):\n                acc_value.extend(delta_value)\n                continue\n\n            for delta_entry in delta_value:\n                if not is_dict(delta_entry):\n                    raise TypeError(f\"Unexpected list delta entry is not a dictionary: {delta_entry}\")\n\n                try:\n                    index = delta_entry[\"index\"]\n                except KeyError as exc:\n                    raise RuntimeError(f\"Expected list delta entry to have an `index` key; {delta_entry}\") from exc\n\n                if not isinstance(index, int):\n                    raise TypeError(f\"Unexpected, list delta entry `index` value is not an integer; {index}\")\n\n                try:\n                    acc_entry = acc_value[index]\n                except IndexError:\n                    acc_value.insert(index, delta_entry)\n                else:\n                    if not is_dict(acc_entry):\n                        raise TypeError(\"not handled yet\")\n\n                    acc_value[index] = accumulate_delta(acc_entry, delta_entry)","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/lib/streaming/_deltas.py#L24-L60","documentation":"Same accumulator check as in _assistants.py, raised by accumulate_delta in _deltas.py (used by Chat Completions and Responses streaming accumulation): a list delta entry that is not a dictionary cannot be index-merged, so it is rejected with this TypeError.","triggerScenarios":"Streaming chat/responses where a list-valued delta contains non-dict entries after the scalar fast-path no longer applies; schema changes in streaming output (e.g. content parts, tool call arguments lists); custom test deltas with scalar entries.","commonSituations":"Pinned older SDK against a newer API; beta features emitting new list shapes; hand-written delta fixtures.","solutions":["Upgrade the openai SDK to the latest version","Make every list delta entry a dict with an integer index key","Catch TypeError and fall back to replacing the accumulated list","Report reproducible payloads to OpenAI"],"exampleFix":"# before\nacc = accumulate_delta(acc, {\"choices\": [\"bad\"]})\n\n# after\nacc = accumulate_delta(acc, {\"choices\": [{\"index\": 0, \"delta\": {\"content\": \"ok\"}}]})","handlingStrategy":"validation","validationCode":"def list_delta_ok(value: list) -> bool:\n    return all(isinstance(e, dict) for e in value)","typeGuard":"def is_scalar_list(value: list) -> bool:\n    return all(isinstance(x, (str, int, float)) for x in value)","tryCatchPattern":"try:\n    acc = accumulate_delta(acc, delta)\nexcept TypeError:\n    acc[key] = copy.deepcopy(delta[key])","preventionTips":["Keep SDK and API versions aligned","Construct list delta entries as dicts with index","Validate custom fixtures"],"tags":["streaming","delta-accumulation","typeerror","schema-mismatch","python"],"backgroundTag":"delta-schema-mismatch","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}