openai/openai-python · error · TypeError

not handled yet

Error message

not handled yet

What it means

Raised inside accumulate_delta when an indexed list delta entry resolves to an existing accumulated entry (no IndexError) but that existing entry is not a dict, so recursive merging cannot proceed. This signals mixed-type lists (scalars and dicts) in accumulated state - a shape the accumulator explicitly does not support yet, hence the 'not handled yet' placeholder.

Source

Thrown at src/openai/lib/streaming/_assistants.py:1035

            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

  1. Upgrade the openai SDK - accumulator support for new payload shapes lands with schema updates
  2. Avoid feeding mixed scalar/dict lists into accumulate_delta in custom code
  3. Reset the accumulated list (start from the latest snapshot) instead of continuing accumulation after schema drift
  4. Report the event sequence to OpenAI if reproducible on current versions

Example fix

# before
acc = {"items": ["a", "b"]}
acc = accumulate_delta(acc, {"items": [{"index": 0, "text": "x"}]})  # raises

# after
acc = {"items": [{"index": 0, "text": "x"}]}  # reset state, don't mix types
Defensive patterns

Strategy: fallback

Validate before calling

null

Type guard

null

Try / catch

try:
    acc = accumulate_delta(acc, delta)
except TypeError as e:
    if str(e) == "not handled yet":
        acc[key] = copy.deepcopy(delta[key])  # reset the list

Prevention

When it happens

Trigger: A list that was first extended with scalar values (str/int/float fast path) later receiving dict entries at those indices, so acc_value[index] is a scalar while delta_entry is a dict; occurs with schema-evolving streaming payloads or synthetic fixtures.

Common situations: Beta API fields whose list contents changed type between events; SDK version older than the API contract; fuzz/property tests feeding mixed-type lists.

Related errors


AI-assisted analysis of openai/openai-python@9917c6e28e (2026-08-28). Data as JSON: /api/errors/b300fcd88d4700c1. Report an issue: GitHub.