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) <noreply@anthropic.com>
This commit is contained in:
samtsai15 2026-08-27 15:08:18 +08:00
parent 0e1ec44e35
commit 355a444944

View file

@ -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")