From 355a44494403584c7180fd297b4fd0682567398f Mon Sep 17 00:00:00 2001 From: samtsai15 <6171228+samtsai15@users.noreply.github.com> Date: Thu, 27 Aug 2026 15:08:18 +0800 Subject: [PATCH] fix: forward max_bytes only when the caller set one `process_image_async` passed `max_bytes=` on every call. The parameter has a default, so the signature stayed compatible, but the *call* did not: an override or test stub written against the previous signature now gets an unexpected keyword and raises. test_url_with_format_param caught it. It stubs `get_image_details_async` with a one-parameter fake, so the model call died on TypeError and the provider mock it asserts on was never reached. Omitting the keyword when there is nothing to cap leaves the model-call image paths byte-for-byte as they were, which is what the parameter being additive was supposed to mean. Co-Authored-By: Claude Opus 5 (1M context) --- litellm/litellm_core_utils/prompt_templates/factory.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py index dafdf986c33..e59982e54c2 100644 --- a/litellm/litellm_core_utils/prompt_templates/factory.py +++ b/litellm/litellm_core_utils/prompt_templates/factory.py @@ -3608,7 +3608,12 @@ class BedrockImageProcessor: if "base64" in image_url: img_bytes, mime_type, image_format = cls._parse_base64_image(image_url) elif "http://" in image_url or "https://" in image_url: - img_bytes, mime_type = await BedrockImageProcessor.get_image_details_async(image_url, max_bytes=max_bytes) + # Forward max_bytes only when the caller set one. Passing it + # unconditionally would reach every override and test stub written + # against the previous signature, so an additive parameter would + # break them; omitting it keeps the call byte-for-byte as it was. + capped: Final = {} if max_bytes is None else {"max_bytes": max_bytes} # mutable-ok: kwargs for one call + img_bytes, mime_type = await BedrockImageProcessor.get_image_details_async(image_url, **capped) image_format = mime_type.split("/")[1] else: raise ValueError("Unsupported image type. Expected either image url or base64 encoded string")