diff --git a/litellm/litellm_core_utils/url_utils.py b/litellm/litellm_core_utils/url_utils.py index ec3afe7276e..50cdc679f9b 100644 --- a/litellm/litellm_core_utils/url_utils.py +++ b/litellm/litellm_core_utils/url_utils.py @@ -443,7 +443,7 @@ async def _async_get_capped( client: object, url: str, max_bytes: int, - request_kwargs: dict[str, object], # mutable-ok: forwarded straight to httpx as **kwargs + request_kwargs: dict[str, Any], # mutable-ok: forwarded straight to httpx as **kwargs ) -> httpx.Response: """GET ``url``, aborting the transfer once the body exceeds ``max_bytes``. @@ -483,7 +483,7 @@ async def async_safe_get(client: Any, url: str, max_bytes: int | None = None, ** async def _issue( target_url: str, - request_kwargs: dict[str, object], # mutable-ok: forwarded straight to httpx as **kwargs + request_kwargs: dict[str, Any], # mutable-ok: forwarded straight to httpx as **kwargs ) -> httpx.Response: if max_bytes is None: return await client.get(target_url, **request_kwargs) @@ -496,7 +496,7 @@ async def async_safe_get(client: Any, url: str, max_bytes: int | None = None, ** caller_headers: Final = kwargs.pop("headers", {}) for _ in range(_MAX_REDIRECTS): validated_url, original_host = validate_url(url) - hop_kwargs: dict[str, object] = { # mutable-ok: a fresh per-hop kwargs dict, consumed by this call + hop_kwargs: dict[str, Any] = { # mutable-ok: a fresh per-hop kwargs dict, consumed by this call **kwargs, "headers": {**caller_headers, "Host": original_host}, # mutable-ok: httpx takes headers as a dict "follow_redirects": False, diff --git a/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py b/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py index b49040580f7..2e9971697cd 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py +++ b/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py @@ -3465,7 +3465,11 @@ class BedrockGuardrail(CustomGuardrail, BaseAWSLLM): ), finish_reason="stop", ) - for _idx, _msg in enumerate(filtered_messages) + # `or ()`: skip_scan is now bypassed when an image is present, + # and images exist on the request side only, so a response scan + # still always has messages here. Spelled out rather than left + # leaning on that indirection. + for _idx, _msg in enumerate(filtered_messages or ()) ] ) bedrock_response = await self.make_bedrock_api_request(