Skip to content

Conversation

@langpingxue
Copy link
Contributor

@langpingxue langpingxue commented Oct 17, 2025

Problem

When using Bedrock with S3-hosted files, if the S3 object's Content-Type is not correctly set (e.g., binary/octet-stream instead of image/png), Bedrock fails to recognize the files format.

Solution

Implemented two-tier fallback mechanism:

  1. URL extension inference - Extract file extension from URL (e.g., .pngimage/png)
  2. Binary content detection - Inspect magic bytes to detect PNG, JPEG, GIF, WebP, HEIC

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature

Changes

  • Modified BedrockImageProcessor._post_call_image_processing() to add fallback logic
  • Added 8 comprehensive unit tests covering all scenarios

New test passing locally

Screenshot 2025-10-17 at 13 04 33

@vercel
Copy link

vercel bot commented Oct 17, 2025

Someone is attempting to deploy a commit to the CLERKIEAI Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Oct 17, 2025

CLA assistant check
All committers have signed the CLA.

@langpingxue
Copy link
Contributor Author

@krrishdholakia Could you help review and merge this PR?
Seems many files in S3 aren’t set with the correct content-type by default.

@langpingxue
Copy link
Contributor Author

@ishaan-jaff Could you help review and merge this PR?
Many files in S3 aren’t set with the correct content-type by default.

Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed

)

# Fallback logic when content-type is missing or generic
if not content_type or content_type in ["binary/octet-stream", "application/octet-stream"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have this be a helper in litellm_core_utils

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, updated.
Thank you!

Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ishaan-jaff ishaan-jaff merged commit 5bba1e8 into BerriAI:main Oct 29, 2025
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants