Skip to content

fix: base64 encode Google inline image bytes - #1

Open
aspire488 wants to merge 3 commits into
mainfrom
fix/google-inline-image-base64
Open

aspire488 wants to merge 3 commits into
mainfrom
fix/google-inline-image-base64

Conversation

@aspire488

Copy link
Copy Markdown
Owner

Problem or current behavior

Result or new behavior

Compatibility and migration

Validation

Agent review

Summary

Fixes conversion of Google GenAI inline image data in
messages_from_google().

Blob.data contains raw bytes, but the current conversion decodes those
bytes as UTF-8 before passing them to as_data_uri(). Real image bytes can
therefore raise UnicodeDecodeError, and UTF-8-decodable bytes can produce
invalid base64 payloads.

Changes

  • Base64-encode raw inline_data.data bytes before constructing the data URI.
  • Check explicitly for None rather than truthiness.
  • Add a regression test using binary PNG bytes.

This mirrors the existing Google provider conversion path.

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.

1 participant