Skip to content

Use detected MIME types for OpenAI image attachments#433

Open
dhrupo wants to merge 1 commit intolaravel:0.xfrom
dhrupo:fix-openai-image-attachment-mime
Open

Use detected MIME types for OpenAI image attachments#433
dhrupo wants to merge 1 commit intolaravel:0.xfrom
dhrupo:fix-openai-image-attachment-mime

Conversation

@dhrupo
Copy link
Copy Markdown

@dhrupo dhrupo commented Apr 21, 2026

Summary

Fix OpenAI image attachment mapping for local and stored image files.

Problem

Files\Image::fromPath() could produce an invalid OpenAI image data URL because the OpenAI attachment mapper used the raw image MIME property instead of the file's detected MIME type. When the MIME property was unset, requests could be sent as data:;base64,..., which OpenAI rejects with a 400 error.

Fixes #417

Solution

Updated the OpenAI attachment mapper to use mimeType() for local and stored image attachments, while preserving the existing image/png fallback when MIME detection is unavailable.

Tests

Added regression tests covering:

  • local .jpg images mapped as data:image/jpeg;base64,...
  • stored .jpg images mapped as data:image/jpeg;base64,...

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.

Files\Image::fromPath attachment causes 400 error when using OpenAI provider

1 participant