{"record":{"id":"17c956b2996ac42b","repo":"openai/openai-python","slug":"unexpected-list-delta-entry-index-value-is-not-17c956","errorCode":null,"errorMessage":"Unexpected, list delta entry `index` value is not an integer; {index}","messagePattern":"Unexpected, list delta entry `index` value is not an integer; (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/openai/lib/streaming/_deltas.py","lineNumber":50,"sourceCode":"            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)\n\n        acc[key] = acc_value\n\n    return acc\n","sourceCodeStart":32,"sourceCodeEnd":65,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/lib/streaming/_deltas.py#L32-L65","documentation":"Raised by accumulate_delta in _deltas.py when a list delta entry has an index of the wrong type (not an int, e.g. string or None). List merging uses the value directly as a Python list index, so non-integer indices are rejected with this TypeError echoing the value.","triggerScenarios":"Streaming deltas where index arrives as a string or null; proxies/middleware altering JSON types; test fixtures with stringified indices.","commonSituations":"Serialization differences in beta APIs; SDK version mismatches; hand-normalized payloads.","solutions":["Coerce/ensure index is int before accumulating custom deltas","Upgrade the SDK to the current release","Validate delta shape in custom accumulation pipelines","Catch TypeError and replace the list as fallback"],"exampleFix":"# before\nentry = {\"index\": None, \"text\": \"hi\"}\n\n# after\nentry = {\"index\": 0, \"text\": \"hi\"}","handlingStrategy":"validation","validationCode":"def indices_are_ints(entries) -> bool:\n    return all(type(e.get(\"index\")) is int for e in entries if isinstance(e, dict))","typeGuard":"null","tryCatchPattern":"try:\n    acc = accumulate_delta(acc, delta)\nexcept TypeError:\n    acc[key] = copy.deepcopy(delta[key])","preventionTips":["Coerce index to int in custom producers","Beware proxies rewriting JSON types","Upgrade SDK with serialization changes"],"tags":["streaming","delta-accumulation","typeerror","python"],"backgroundTag":"delta-schema-mismatch","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}