{"record":{"id":"c158b62a179f9be3","repo":"openai/openai-python","slug":"unknown-array-format-value-array-format-choose-c158b6","errorCode":null,"errorMessage":"Unknown array_format value: {array_format}, choose from {', '.join(get_args(ArrayFormat))}","messagePattern":"Unknown array_format value: (.+?), choose from (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"warning","filePath":"src/openai/_utils/_utils.py","lineNumber":74,"sourceCode":"\n    Note: this mutates the given dictionary.\n    \"\"\"\n    files: list[tuple[str, FileTypes]] = []\n    for path in paths:\n        files.extend(_extract_items(query, path, index=0, flattened_key=None, array_format=array_format))\n    return files\n\n\ndef _array_suffix(array_format: ArrayFormat, array_index: int) -> str:\n    if array_format == \"brackets\":\n        return \"[]\"\n    if array_format == \"indices\":\n        return f\"[{array_index}]\"\n    if array_format == \"repeat\" or array_format == \"comma\":\n        # Both repeat the bare field name for each file part; there is no\n        # meaningful way to comma-join binary parts.\n        return \"\"\n    raise NotImplementedError(\n        f\"Unknown array_format value: {array_format}, choose from {', '.join(get_args(ArrayFormat))}\"\n    )\n\n\ndef _extract_items(\n    obj: object,\n    path: Sequence[str],\n    *,\n    index: int,\n    flattened_key: str | None,\n    array_format: ArrayFormat,\n) -> list[tuple[str, FileTypes]]:\n    try:\n        key = path[index]\n    except IndexError:\n        if not is_given(obj):\n            # no value was provided - we can safely ignore\n            return []","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/_utils/_utils.py#L56-L92","documentation":"When the SDK serializes sequences for multipart/form-data uploads it computes a per-item field-name suffix based on the configured ArrayFormat ('indices', 'repeat', or 'comma'). _array_suffix raises NotImplementedError when it receives any other value, which in practice cannot happen through public APIs — it guards the internal contract. Seeing it means custom code invoked the transform internals with an array_format string outside the allowed set.","triggerScenarios":"Calling the SDK's internal multipart transform utilities directly with array_format set to something other than the literal values of ArrayFormat (e.g. 'brackets' or a translated/localized copy); monkeypatching internals during tests with an invalid constant.","commonSituations":"Test code patching serialization internals; forks or copy-pasted transform code drifting from the original; passing a variable that shadowed the ArrayFormat literal with a typo.","solutions":["Use only the documented ArrayFormat literal values: 'indices', 'repeat', 'comma'","Avoid calling private transform helpers directly; construct uploads through the public client methods","Fix typos in the array_format variable feeding the transform","If patching in tests, patch with one of the real literals"],"exampleFix":"# before\n_array_suffix(item, array_format=\"brackets\", array_index=0)\n\n# after\nfrom openai._utils import _array_suffix\n_array_suffix(item, array_format=\"indices\", array_index=0)","handlingStrategy":"validation","validationCode":"from typing import get_args\nfrom openai._utils._utils import ArrayFormat  # adjust import\nassert fmt in get_args(ArrayFormat), f\"bad format {fmt}\"","typeGuard":"def is_valid_array_format(v: str) -> bool:\n    return v in {\"indices\", \"repeat\", \"comma\"}","tryCatchPattern":"try:\n    serialize(items, fmt)\nexcept NotImplementedError:\n    fmt = \"indices\"; serialize(items, fmt)","preventionTips":["Use documented ArrayFormat literals only","Don't call private transform helpers","Keep patched constants in tests consistent with real ones"],"tags":["notimplementederror","internal-api","serialization","multipart"],"backgroundTag":"unsupported-serialization-format","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}