Skip to content

Conversation

@GeneCodeSavvy
Copy link

Fixes #9512

What does this PR do?

Improve validation against file signatures from Wikipedia's file signature reference to be more robust:

  • PNG: Validate full 8-byte signature (89 50 4E 47 0D 0A 1A 0A)
  • JPEG: Validate 3-byte start marker (FF D8 FF)
  • GIF: Check for GIF87a or GIF89a (6-byte format)
  • WebP: Validate RIFF...WEBP structure (12-byte check)
  • PDF: Validate PDF header (25 50 44 46)

Add comprehensive test coverage for invalid GIF and PDF files to ensure the robust validation catches misnamed/corrupted files across all formats.

How did you verify your code works?

Screen.Recording.2026-01-21.at.15.05.03.mov

…king

Improve validation against file signatures from Wikipedia's file
signature
reference to be more robust:

- PNG: Validate full 8-byte signature (89 50 4E 47 0D 0A 1A 0A)
- JPEG: Validate 3-byte start marker (FF D8 FF)
- GIF: Check for GIF87a or GIF89a (6-byte format)
- WebP: Validate RIFF...WEBP structure (12-byte check)
- PDF: Validate PDF header (25 50 44 46)

Add comprehensive test coverage for invalid GIF and PDF files to ensure
the robust validation catches misnamed/corrupted files across all
formats.
@github-actions
Copy link
Contributor

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

No duplicate PRs found

@mmkal
Copy link

mmkal commented Jan 21, 2026

This looks useful, but I don't think it's a fix for the underlying issue in #9512. The biggest problem there was that whatever caused an error to be thrown bricked the whole session, rather than what it would usually do - tell opencode "XYZ went wrong", so it can smartly figure out what to do instead (in this case go back and figure out why it had an invalid .jpeg file in the first place)

@GeneCodeSavvy
Copy link
Author

The session isn't being bricked anymore. For the agent to troubleshoot, prompting it to do so would also work now.
Refer to the attached video

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.

Trying to read an invalid image file bricks the session

2 participants