Skip to content

🪲 BUG-#12: Preserve real image MIME type instead of hardcoding image/png - #13

Merged
FernandoCelmer merged 2 commits into
masterfrom
feature/12
Aug 15, 2026
Merged

🪲 BUG-#12: Preserve real image MIME type instead of hardcoding image/png#13
FernandoCelmer merged 2 commits into
masterfrom
feature/12

Conversation

@FernandoCelmer

@FernandoCelmer FernandoCelmer commented Aug 15, 2026

Copy link
Copy Markdown
Member

Description

Fixes hardcoded image/png MIME type in to_openai_messages and to_anthropic_messages. Introduces _split_image() to extract the real MIME type from data:<mime>;base64,<data> URLs, while falling back to image/png for bare base64 strings (backward-compatible).

Closes #12

Related: dotflow-io/vscodeloop#3

Motivation and Context

Images of any type (JPEG, WebP, GIF, etc.) were being sent to providers as image/png, causing provider-side validation errors or silent misinterpretation. The extension currently strips the data: prefix before sending, so both sides need the fix end-to-end.

Types of changes

  • Bug fix
  • New feature
  • Documentation

Checklist

  • Self-review done
  • Tests added (+2 new: one for Anthropic, one for OpenAI)
  • CHANGELOG updated
  • Docs updated

@FernandoCelmer FernandoCelmer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Code Review

Code issues found: 1

# Severity Comment
1 [Suggestion] Regex: re.DOTALL + ambiguous +- range in MIME character class

Comment thread pycodeloop/providers/_shapes.py
@FernandoCelmer FernandoCelmer added the bug Something isn't working label Aug 15, 2026
@FernandoCelmer
FernandoCelmer merged commit 70f07ce into master Aug 15, 2026
8 checks passed
@FernandoCelmer
FernandoCelmer deleted the feature/12 branch August 15, 2026 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image messages hardcode image/png regardless of the actual MIME type

1 participant