feat(intelligent-assistant): accept WebP image attachments on /v1/query - #4512
feat(intelligent-assistant): accept WebP image attachments on /v1/query#4512JslYoon wants to merge 2 commits into
Conversation
Add WebP (image/webp) as a supported filetype for screen context attachments, alongside the existing JPEG support. Images are validated by magic bytes: WebP files are a RIFF container with "RIFF" at offset 0 and "WEBP" at offset 8. Updates the vision-unsupported error message to be filetype-agnostic and adds unit and end-to-end tests covering WebP accept, data-URL WebP, and invalid magic-byte rejection. Requires WebP support on the lightspeed-stack /query route (lightspeed-core/lightspeed-stack#2556). Assisted-by: Claude Opus 4.8 Signed-off-by: Lucas <lyoon@redhat.com>
|
Important This PR includes changes that affect public-facing API. Please ensure you are adding/updating documentation for new features or behavior. Changed Packages
|
|
/s-review |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4512 +/- ##
==========================================
- Coverage 61.81% 61.79% -0.03%
==========================================
Files 2587 2583 -4
Lines 103335 103253 -82
Branches 29014 28926 -88
==========================================
- Hits 63875 63801 -74
- Misses 37601 38897 +1296
+ Partials 1859 555 -1304
*This pull request uses carry forward flags. Click here to find out more. Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
|
New changes are detected. LGTM label has been removed. |
|
|
/fs-review |
|
🤖 Finished Review · ✅ Success · Started 2:09 PM UTC · Completed 2:23 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Cost: $4.75 |
ReviewFindingsLow
Labels: PR adds a feature to the intelligent-assistant workspace. |
|
|
||
| function hasValidJpegMagicBytes(content: string): boolean { | ||
| const bytes = Buffer.from(extractBase64(content), 'base64'); | ||
| function matchesMagic(bytes: Buffer, magic: number[], offset = 0): boolean { |
There was a problem hiding this comment.
[low] naming convention
The new matchesMagic helper function returns a boolean but does not follow the has*/is* prefix convention established by the other boolean-returning private functions in the same file (hasValidImageMagicBytes, isValidJson).
Suggested fix: Consider renaming to hasMagicBytes or isMagicMatch.



Summary
Adds WebP (
image/webp) as a supported filetype for screen context attachments on the/v1/queryroute, alongside the existing JPEG support.Image attachments are validated by their magic bytes. WebP files are a RIFF container —
RIFFat offset 0 andWEBPat offset 8 — so both markers are checked. JPEG validation is unchanged.The vision-unsupported error message is updated to be filetype-agnostic (
does not support image attachments) now that more than one image type is accepted.Changes
validation.ts— accept WebP magic bytes alongside JPEG (hasValidImageMagicBytes); update error messages.validation.test.ts— unit tests for WebP accept (raw + data URL) and updated reject message.router.test.ts— end-to-end/v1/querytests for WebP accept and invalid magic-byte rejection.Testing
yarn test— 107 passing across the two suites.RIFF...WEBP VP8), run through the actualvalidateAttachmentsForModelmiddleware: real WebP and data-URL WebP accepted; truncated RIFF rejected.Related
Depends on WebP support on the lightspeed-stack
/queryroute: lightspeed-core/lightspeed-stack#2556.🤖 Generated with Claude Code