From a46896b4369eaeb66ef2cdad6e07eb4bc289db83 Mon Sep 17 00:00:00 2001 From: "feng.tsai" Date: Thu, 3 Sep 2026 03:47:40 +0800 Subject: [PATCH] fix(guardrails): avoid empty-dict default to satisfy type-discipline budget The merge with litellm_internal_staging tightened the LIT002 (mutable-collection construction) ceiling to exactly the current count, so the `.get("source", {})` default pushed the count 1 over budget. Reworked to check `source` before indexing instead of constructing a throwaway empty dict. --- .../proxy/guardrails/guardrail_hooks/bedrock_guardrails.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py b/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py index 13c7b611e8a..9788b7dd9ee 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py +++ b/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py @@ -617,8 +617,8 @@ class BedrockGuardrail(CustomGuardrail, BaseAWSLLM): image_format: Final = ( _APPLY_GUARDRAIL_IMAGE_FORMATS.get(str(image_block.get("format"))) if image_block else None ) - # mutable-ok: {} is an empty default for .get, never mutated - image_bytes: Final = image_block.get("source", {}).get("bytes") if image_block else None + image_source: Final = image_block.get("source") if image_block else None + image_bytes: Final = image_source.get("bytes") if image_source else None if image_format is None or not image_bytes: self._handle_unscannable_image(reason="attachment is not a png/jpeg image") return None