openai/openai-python · error · TypeError

not handled yet

Error message

not handled yet

What it means

Raised by accumulate_delta in _deltas.py when an indexed dict delta entry targets an accumulated list slot that already holds a non-dict value, making recursive merge impossible. The literal 'not handled yet' message marks an explicitly unsupported accumulated-state shape (mixed scalar/dict lists).

Source

Thrown at src/openai/lib/streaming/_deltas.py:58

            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 to pick up accumulator schema fixes
  2. Do not mix scalar and dict entries in lists fed to accumulate_delta
  3. Restart accumulation from a fresh snapshot after detecting schema drift
  4. Report the event sequence if it reproduces on the latest version

Example fix

# before
acc = {"content": ["plain text"]}
acc = accumulate_delta(acc, {"content": [{"index": 0, "text": "x"}]})  # raises

# after
acc = {"content": [{"index": 0, "text": "x"}]}  # rebuild from snapshot
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])

Prevention

When it happens

Trigger: A list first filled via the scalar extend fast-path subsequently receiving a dict entry at an existing index during Chat/Responses streaming; schema-evolving output fields or synthetic mixed-type fixtures.

Common situations: API fields changing list element types mid-stream across versions; older SDKs accumulating newer payloads; fuzz tests.

Related errors


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