Issue with get_file_page_screenshot() in Python library #467

Open
opened 2026-02-16 00:17:56 -05:00 by yindo · 0 comments
Owner

Originally created by @donpulpo on GitHub (May 4, 2025).

Describe the bug
I get an error when calling client.files.get_file_page_screenshot(id="report_id",page_index=1)

Recreating issue is fairly simple and happens on all PDFs

from llama_cloud.client import LlamaCloud
client = LlamaCloud(token='MY_TOKEN')
data=client.files.get_file_page_screenshot(id="report_id",page_index=1)

The error message is

UnicodeDecodeError Traceback (most recent call last)
in <cell line: 0>()
----> 1 data=client.files.get_file_page_screenshot(id="xxx",page_index=1)
2 #client.files.list_file_page_screenshots(id="xxx")

2 frames
/usr/lib/python3.11/json/__init__.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
339 raise TypeError(f'the JSON object must be str, bytes or bytearray, '
340 f'not {s.class.name}')
--> 341 s = s.decode(detect_encoding(s), 'surrogatepass')
342
343 if (cls is None and object_hook is None and

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

If I check the source code, the issue happens in client.py. line 460
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore

The call to .json() is throwing an error as the result is a binary.
Changing this line to
return pydantic.parse_obj_as(typing.Any, _response.content)

it solve the issue, though not sure this is the right fix

Note that calling the request directly does not throw an error

Files
any PDF file

Client:
Please remove untested options:

  • Python Library : llama-cloud-0.1.19
Originally created by @donpulpo on GitHub (May 4, 2025). **Describe the bug** I get an error when calling client.files.get_file_page_screenshot(id="report_id",page_index=1) Recreating issue is fairly simple and happens on all PDFs ``` from llama_cloud.client import LlamaCloud client = LlamaCloud(token='MY_TOKEN') data=client.files.get_file_page_screenshot(id="report_id",page_index=1) ``` The error message is --------------------------------------------------------------------------- UnicodeDecodeError Traceback (most recent call last) [<ipython-input-4-4c3201844a51>](https://localhost:8080/#) in <cell line: 0>() ----> 1 data=client.files.get_file_page_screenshot(id="xxx",page_index=1) 2 #client.files.list_file_page_screenshots(id="xxx") 2 frames [/usr/lib/python3.11/json/__init__.py](https://localhost:8080/#) in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 339 raise TypeError(f'the JSON object must be str, bytes or bytearray, ' 340 f'not {s.__class__.__name__}') --> 341 s = s.decode(detect_encoding(s), 'surrogatepass') 342 343 if (cls is None and object_hook is None and **UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte** If I check the source code, the issue happens in client.py. line 460 if 200 <= _response.status_code < 300: **return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore** The call to .json() is throwing an error as the result is a binary. Changing this line to return pydantic.parse_obj_as(typing.Any, **_response.content**) it solve the issue, though not sure this is the right fix Note that calling the request directly does not throw an error **Files** any PDF file **Client:** Please remove untested options: - Python Library : llama-cloud-0.1.19
yindo added the bug label 2026-02-16 00:17:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/llama_cloud_services#467