openai/openai-python · error · TypeError
Unexpected, list delta entry `index` value is not an integer
Error message
Unexpected, list delta entry `index` value is not an integer; {index} What it means
Raised inside accumulate_delta when a list delta entry's index value is present but not an int (e.g. a string '0' or None). The merger indexes Python lists with it, so a non-integer index is rejected with this TypeError showing the bad value.
Source
Thrown at src/openai/lib/streaming/_assistants.py:1027
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)
acc[key] = acc_value
return acc
View on GitHub (pinned to 9917c6e28e)
Solutions
- Ensure index is a plain int (json.loads yields int for JSON numbers - check for manual coercion)
- Upgrade the SDK to match the current API schema
- Validate/normalize delta entries before accumulation in custom pipelines
- Catch TypeError and replace the accumulated list as a fallback
Example fix
# before
entry = {"index": "0", "text": "hi"}
# after
entry = {"index": 0, "text": "hi"} Defensive patterns
Strategy: validation
Validate before calling
def entries_have_int_index(entries) -> bool:
return all(
isinstance(e, dict) and type(e.get("index")) is int for e in entries
) Type guard
null
Try / catch
try:
acc = accumulate_delta(acc, delta)
except TypeError:
acc[key] = copy.deepcopy(delta) Prevention
- Normalize index to int before accumulating custom deltas
- Watch for middleware that stringifies JSON values
- Upgrade SDK when API serialization changes
When it happens
Trigger: Delta payloads where index is serialized as a string or null; schema changes in beta streaming endpoints; test fixtures using JSON-ish typed indices.
Common situations: Version mismatch between SDK accumulator strictness and API serialization; middleware/proxies rewriting JSON; handcrafted delta dicts in unit tests.
Related errors
- Unexpected list delta entry is not a dictionary: {delta_entr
- Unexpected list delta entry is not a dictionary: {delta_entr
- Unexpected, list delta entry `index` value is not an integer
- Encountered a message delta with no previous snapshot
- Expected list delta entry to have an `index` key; {delta_ent
AI-assisted analysis of openai/openai-python@9917c6e28e (2026-08-28).
Data as JSON: /api/errors/48547f7f3dd3a332.
Report an issue: GitHub.