Skip to content

fix(read): reject unsupported image formats before sending to provider#21114

Open
zeke wants to merge 1 commit intoanomalyco:devfrom
zeke:fix-unsupported-image-formats
Open

fix(read): reject unsupported image formats before sending to provider#21114
zeke wants to merge 1 commit intoanomalyco:devfrom
zeke:fix-unsupported-image-formats

Conversation

@zeke
Copy link
Copy Markdown
Contributor

@zeke zeke commented Apr 5, 2026

Issue for this PR

Closes #17772
Closes #15264

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This PR adds an allowlist of provider-supported image formats (JPEG, PNG, GIF, WebP) to the Read tool. Previously, any image/* MIME type (except SVG and fastbidsheet) was base64-encoded and sent to the LLM provider. Formats like BMP, TIFF, AVIF, and HEIC were accepted by the Read tool but rejected by the provider API, and because the unsupported attachment was persisted in conversation history, every subsequent message replayed it — making the session unrecoverable.

Unsupported image formats now return a clear error message instead of silently passing through.

There's also #17774 which takes a different approach by auto-converting unsupported formats to PNG using sharp/sips/ffmpeg. That's a nice idea but a bigger change with new dependencies and more failure modes. This PR is a two-line fix that stops the session-poisoning bug immediately. Auto-conversion could be layered on top of this later.

How did you verify your code works?

Added three test cases for BMP, TIFF, and AVIF rejection. All 38 read tool tests pass. Typecheck passes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The Read tool accepted any image/* MIME type (except SVG and fastbidsheet)
and sent it to the LLM provider. Providers like Anthropic only support
JPEG, PNG, GIF, and WebP, so formats like BMP, TIFF, AVIF, and HEIC
caused API validation errors. Because the unsupported attachment was
persisted in the conversation history, every subsequent message replayed
it, making the session unrecoverable.

Closes anomalyco#17772
Closes anomalyco#15264
@github-actions github-actions bot added contributor needs:compliance This means the issue will auto-close after 2 hours. labels Apr 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

The following comment was made by an LLM, it may be inaccurate:

Found a potential duplicate:

PR #17774: feat: auto-convert unsupported image formats (AVIF, HEIC) to PNG
#17774

This PR is directly related to the current PR #21114. Both address the same problem with unsupported image formats (AVIF, HEIC, BMP, TIFF) in the Read tool. However, they propose different solutions:

You may want to check if #17774 is still open or if there's been a decision on which approach is preferred.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@zeke
Copy link
Copy Markdown
Contributor Author

zeke commented Apr 5, 2026

Hey @rekram1-node and @thdxr — this is a small fix for the issues you two are assigned to (#17772 and #15264). It adds an allowlist of supported image formats so unsupported ones like BMP/AVIF/HEIC get rejected with a clear error instead of poisoning the session.

Would love your eyes on it when you get a chance. And thanks for building OpenCode — it's been a life-changer for me! 🧡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant