{"record":{"id":"67cf79b4835d04c7","repo":"openai/openai-python","slug":"unexpected-list-delta-entry-is-not-a-dictionary","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/_assistants.py","lineNumber":1019,"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":1001,"sourceCodeEnd":1037,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/lib/streaming/_assistants.py#L1001-L1037","documentation":"Raised inside accumulate_delta when a list-valued delta contains an entry that is not a dict. List deltas are merged by index and each entry is expected to be a dictionary carrying an index key; anything else (string, number, nested list) hits this TypeError. The duplicated logic also exists in _deltas.py used by the Chat/Responses accumulators, so the same payload shape triggers it in both places.","triggerScenarios":"Streaming responses where a list field delta (e.g. annotations, content parts) contains scalar entries: after the first merge pass appends str/int/float scalars, subsequent dict entries in delta_value reach the per-entry check; or server payloads with unexpected list shapes during active development of streaming APIs.","commonSituations":"Using pre-release Responses/Assistants streaming endpoints whose delta schemas changed between SDK and API versions; SDK version lag behind API schema additions; manually constructed delta payloads in tests.","solutions":["Upgrade (or align) the openai SDK to the version matching the API schema you are streaming from","If you build deltas yourself, ensure list entries are dicts containing an integer index key","Report the payload shape to OpenAI if it occurs against a stable, current SDK","As a stopgap, catch TypeError around accumulation and fall back to replacing the list"],"exampleFix":"# before\nresult = accumulate_delta(acc, delta)  # raises TypeError on scalar entries\n\n# after\ntry:\n    result = accumulate_delta(acc, delta)\nexcept TypeError:\n    result = copy.deepcopy(delta)  # replace wholesale as fallback","handlingStrategy":"validation","validationCode":"def delta_entries_valid(delta_value) -> bool:\n    return all(isinstance(e, dict) for e in delta_value) or all(\n        isinstance(e, (str, int, float)) for e in delta_value\n    )","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)  # replace list wholesale","preventionTips":["Keep SDK version aligned with the API schema you stream from","Make list delta entries dicts with integer index keys","Add shape assertions in custom accumulation pipelines"],"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"}