Limit the size of fetched remote files
Merged
PU
1d ago+118+118+012345678901234567890123456789-5-5-0123456789
Today
RemoteImage,RemoteDocument,RemoteAudioandRemoteVideodownload the full file before they inline or upload it.- The download has no size limit, and a compressed body expands with no limit.
Problem
- A very large file fills worker memory and temporary storage.
- The request then fails late, with a memory error instead of a clear message.
Change
- A download stops at 100 MB and throws an
InvalidArgumentExceptionthat names the limit. - A file whose
Content-Lengthis over the limit fails before the body downloads. - The limit counts the decoded bytes, so compressed bodies are limited too.
[!NOTE]
Remote files over 100 MB now throw. Set ai.remote_files.max_size (in kilobytes) to change the limit.