openai/openai-python · error · TypeError
Unexpected list delta entry is not a dictionary: {delta_entr
Error message
Unexpected list delta entry is not a dictionary: {delta_entry} What it means
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.
Source
Thrown at src/openai/lib/streaming/_deltas.py:42
acc[key] = delta_value
continue
if isinstance(acc_value, str) and isinstance(delta_value, str):
acc_value += delta_value
elif isinstance(acc_value, (int, float)) and isinstance(delta_value, (int, float)):
acc_value += delta_value
elif is_dict(acc_value) and is_dict(delta_value):
acc_value = accumulate_delta(acc_value, delta_value)
elif is_list(acc_value) and is_list(delta_value):
# for lists of non-dictionary items we'll only ever get new entries
# in the array, existing entries will never be changed
if all(isinstance(x, (str, int, float)) for x in acc_value):
acc_value.extend(delta_value)
continue
for delta_entry in delta_value:
if not is_dict(delta_entry):
raise TypeError(f"Unexpected list delta entry is not a dictionary: {delta_entry}")
try:
index = delta_entry["index"]
except KeyError as exc:
raise RuntimeError(f"Expected list delta entry to have an `index` key; {delta_entry}") from exc
if not isinstance(index, int):
raise TypeError(f"Unexpected, list delta entry `index` value is not an integer; {index}")
try:
acc_entry = acc_value[index]
except IndexError:
acc_value.insert(index, delta_entry)
else:
if not is_dict(acc_entry):
raise TypeError("not handled yet")
acc_value[index] = accumulate_delta(acc_entry, delta_entry)View on GitHub (pinned to 9917c6e28e)
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
Example fix
# before
acc = accumulate_delta(acc, {"choices": ["bad"]})
# after
acc = accumulate_delta(acc, {"choices": [{"index": 0, "delta": {"content": "ok"}}]}) Defensive patterns
Strategy: validation
Validate before calling
def list_delta_ok(value: list) -> bool:
return all(isinstance(e, dict) for e in value) Type guard
def is_scalar_list(value: list) -> bool:
return all(isinstance(x, (str, int, float)) for x in value) Try / catch
try:
acc = accumulate_delta(acc, delta)
except TypeError:
acc[key] = copy.deepcopy(delta[key]) Prevention
- Keep SDK and API versions aligned
- Construct list delta entries as dicts with index
- Validate custom fixtures
When it happens
Trigger: 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.
Common situations: Pinned older SDK against a newer API; beta features emitting new list shapes; hand-written delta fixtures.
Related errors
- Unexpected list delta entry is not a dictionary: {delta_entr
- Expected list delta entry to have an `index` key; {delta_ent
- Unexpected, list delta entry `index` value is not an integer
- Expected list delta entry to have an `index` key; {delta_ent
- Unexpected, list delta entry `index` value is not an integer
AI-assisted analysis of openai/openai-python@9917c6e28e (2026-08-28).
Data as JSON: /api/errors/e9d842510a6d10ed.
Report an issue: GitHub.