{"record":{"id":"944e34151550a7b3","repo":"BerriAI/litellm","slug":"pages-must-be-a-list-int-0-based-mistral-styl","errorCode":null,"errorMessage":"`pages` must be a list[int] (0-based, Mistral-style) or a string like '1-3,5,7-9'.","messagePattern":"`pages` must be a list\\[int\\] \\(0-based, Mistral-style\\) or a string like '1-3,5,7-9'\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure_ai/ocr/document_intelligence/transformation.py","lineNumber":170,"sourceCode":"            if len(pages) == 0:\n                return \"\"\n            if any(isinstance(p, bool) for p in pages):\n                raise ValueError(\"`pages` must be integers, not booleans\")\n            if all(isinstance(p, int) for p in pages):\n                if any(p < 0 for p in pages):\n                    raise ValueError(\"`pages` integers must be >= 0 (Mistral 0-based indices)\")\n                # Mistral 0-based -> Azure 1-based.\n                return \",\".join(str(p + 1) for p in sorted(set(pages)))\n            if all(isinstance(p, str) for p in pages):\n                joined: Final = \",\".join(p.strip() for p in pages)\n                if not pages_pattern.match(joined):\n                    raise ValueError(\n                        f\"Invalid `pages` list for Azure Document Intelligence: \"\n                        f\"{pages!r}. Expected tokens like '1' or '3-5'.\"\n                    )\n                return joined\n\n        raise ValueError(\"`pages` must be a list[int] (0-based, Mistral-style) or a string like '1-3,5,7-9'.\")\n\n    @staticmethod\n    def _normalize_features_param(features: object) -> str:\n        \"\"\"\n        Convert a caller-provided `features` value to Azure DI's query-string\n        form (comma-joined feature names, e.g. \"keyValuePairs,languages\").\n\n        Accepted inputs:\n          - list[str]: feature names like [\"keyValuePairs\", \"languages\"].\n          - str: a single feature name or comma-separated names.\n        \"\"\"\n        invalid_features_error: Final = ValueError(\n            f\"Invalid `features` for Azure Document Intelligence: {features!r}. \"\n            f\"Expected a list of feature names or a comma-separated string like \"\n            f\"'keyValuePairs' or 'keyValuePairs,languages'.\"\n        )\n\n        if isinstance(features, str):","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure_ai/ocr/document_intelligence/transformation.py#L152-L188","documentation":"Catch-all type error for the `pages` parameter of Azure Document Intelligence OCR: the value is neither a str, a list[int], nor a list[str] (e.g. a tuple, a single int, a dict, or a mixed int/str list). LiteLLM only supports those three shapes when mapping Mistral-style OCR params onto Azure's query string, and mixed lists fail all(isinstance(...)) branches.","triggerScenarios":"Calling azure_ai doc-intelligence OCR with pages=(1, 2) (tuple), pages=3 (bare int), pages={\"pages\": [1]}, or a mixed list like [1, \"3\"].","commonSituations":"Frameworks passing tuples instead of lists; mixed-type lists from untyped configs; assuming a single int page is accepted; pydantic models with Any-typed fields.","solutions":["Pass one of the supported shapes: str ('1-3,5'), list[int] (0-based), or list[str] (1-based tokens).","For a single page as int, wrap it: [2] or '3'.","Normalize mixed lists to one type before the call (e.g. [str(p) for p in pages] — remembering the 1-based semantics of str tokens)."],"exampleFix":"# before\nlitellm.aocr_document(model=..., document=doc, pages=(0, 1))  # tuple -> unsupported\n\n# after\nlitellm.aocr_document(model=..., document=doc, pages=[0, 1])  # list[int], 0-based","handlingStrategy":"type-guard","validationCode":"def normalize_pages(v):\n    if isinstance(v, (list,)) and v and all(isinstance(p, int) and not isinstance(p, bool) for p in v):\n        return v\n    if isinstance(v, str):\n        return v\n    if isinstance(v, (tuple, set)):\n        return list(v)\n    raise TypeError(\"pages must be str, list[int], or list[str]\")","typeGuard":"def is_supported_pages(v: object) -> bool:\n    if isinstance(v, str):\n        return True\n    if isinstance(v, list) and v:\n        return all(isinstance(p, int) and not isinstance(p, bool) for p in v) or all(isinstance(p, str) for p in v)\n    return False","tryCatchPattern":null,"preventionTips":["Normalize tuples/sets to list before the call.","Keep page lists single-type (all int or all str)."],"tags":["azure","document-intelligence","ocr","type-validation","pages"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}