fix: handle invalid image payloads from Read tool#15262
fix: handle invalid image payloads from Read tool#15262LIU9293 wants to merge 2 commits intoanomalyco:devfrom
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR that might be addressing similar image handling concerns: Related PR:
This PR also deals with image handling in the Read tool context, though it focuses on file extension casing rather than payload validation. It might be worth checking if there's any overlap in scope. The current PR (#15262) appears to be unique in its focus on validating image payloads with binary signature checks and base64 sanity checks before provider submission - a more comprehensive validation approach than what I found in the search results. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
ef7d530 to
73e6ff5
Compare
Issue for this PR
Closes #15264
Type of change
What does this PR do?
A malformed image attachment from Read could reach the provider as an image/file part and trigger a hard provider error ("image data does not represent a valid image"), which then caused follow-up turns to keep failing in the same session.
This PR validates image payloads before provider send:
imageparts andfileparts carrying image media (dataor data-urlurl)Also adds regression tests for invalid base64 image parts and invalid image file data.
How did you verify your code works?
bun test test/provider/transform.test.tsinpackages/opencodeimagepartfilepartbun run typecheckinpackages/opencodeScreenshots / recordings
N/A (non-UI change)
Checklist