Skip to content

feat(intelligent-assistant): accept WebP image attachments on /v1/query - #4512

Open
JslYoon wants to merge 2 commits into
redhat-developer:mainfrom
JslYoon:feat/intelligent-assistant-webp-attachments
Open

feat(intelligent-assistant): accept WebP image attachments on /v1/query#4512
JslYoon wants to merge 2 commits into
redhat-developer:mainfrom
JslYoon:feat/intelligent-assistant-webp-attachments

Conversation

@JslYoon

@JslYoon JslYoon commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds WebP (image/webp) as a supported filetype for screen context attachments on the /v1/query route, alongside the existing JPEG support.

Image attachments are validated by their magic bytes. WebP files are a RIFF container — RIFF at offset 0 and WEBP at 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/query tests for WebP accept and invalid magic-byte rejection.
  • changeset (minor bump for the backend package).

Testing

  • yarn test — 107 passing across the two suites.
  • Verified against a real WebP file generated with ImageMagick (RIFF...WEBP VP8), run through the actual validateAttachmentsForModel middleware: real WebP and data-URL WebP accepted; truncated RIFF rejected.

Related

Depends on WebP support on the lightspeed-stack /query route: lightspeed-core/lightspeed-stack#2556.

🤖 Generated with Claude Code

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>
@rhdh-gh-app

rhdh-gh-app Bot commented Sep 1, 2026

Copy link
Copy Markdown

Important

This PR includes changes that affect public-facing API. Please ensure you are adding/updating documentation for new features or behavior.

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/backstage-plugin-intelligent-assistant-backend workspaces/intelligent-assistant/plugins/intelligent-assistant-backend minor v4.1.0

@JslYoon

JslYoon commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

/s-review

@its-mitesh-kumar its-mitesh-kumar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.79%. Comparing base (089172b) to head (0b86b12).
⚠️ Report is 11 commits behind head on main.
✅ All tests successful. No failed tests found.

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     
Flag Coverage Δ *Carryforward flag
adoption-insights 84.55% <ø> (ø) Carriedforward from ba9fec2
ai-integrations 76.15% <ø> (ø) Carriedforward from ba9fec2
app-defaults 55.55% <ø> (ø) Carriedforward from ba9fec2
augment 46.67% <ø> (ø) Carriedforward from ba9fec2
boost 80.00% <ø> (ø) Carriedforward from ba9fec2
bulk-import 72.79% <ø> (ø) Carriedforward from ba9fec2
cost-management 13.55% <ø> (ø) Carriedforward from ba9fec2
dcm 72.09% <ø> (ø) Carriedforward from ba9fec2
e2e-adoption-insights 60.00% <ø> (ø) Carriedforward from ba9fec2
e2e-extensions 62.13% <ø> (ø) Carriedforward from ba9fec2
e2e-global-header 50.00% <ø> (ø) Carriedforward from ba9fec2
e2e-homepage 61.11% <ø> (ø) Carriedforward from ba9fec2
e2e-intelligent-assistant 47.04% <ø> (ø) Carriedforward from ba9fec2
e2e-orchestrator 49.52% <ø> (ø) Carriedforward from ba9fec2
e2e-orchestrator-plugin 49.51% <ø> (ø) Carriedforward from ba9fec2
e2e-quickstart 55.21% <ø> (ø) Carriedforward from ba9fec2
e2e-scorecard 50.21% <ø> (ø) Carriedforward from ba9fec2
e2e-theme 16.36% <ø> (ø) Carriedforward from ba9fec2
extensions 56.59% <ø> (ø) Carriedforward from ba9fec2
global-floating-action-button 71.18% <ø> (ø) Carriedforward from ba9fec2
global-header 67.67% <ø> (-0.38%) ⬇️ Carriedforward from ba9fec2
homepage 48.39% <ø> (ø) Carriedforward from ba9fec2
install-dynamic-plugins 58.57% <ø> (ø) Carriedforward from ba9fec2
intelligent-assistant 75.28% <100.00%> (+0.02%) ⬆️
konflux 91.98% <ø> (ø) Carriedforward from ba9fec2
lightspeed 69.02% <ø> (ø) Carriedforward from ba9fec2
mcp-integrations 84.14% <ø> (ø) Carriedforward from ba9fec2
orchestrator 70.87% <ø> (-0.19%) ⬇️ Carriedforward from ba9fec2
quickstart 63.74% <ø> (ø) Carriedforward from ba9fec2
sandbox 79.56% <ø> (ø) Carriedforward from ba9fec2
scorecard 87.65% <ø> (ø) Carriedforward from ba9fec2
theme 88.76% <ø> (ø) Carriedforward from ba9fec2
translations 5.12% <ø> (ø) Carriedforward from ba9fec2
x2a 77.10% <ø> (ø) Carriedforward from ba9fec2

*This pull request uses carry forward flags. Click here to find out more.


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 089172b...0b86b12. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@openshift-ci openshift-ci Bot removed the lgtm label Sep 1, 2026
@openshift-ci

openshift-ci Bot commented Sep 1, 2026

Copy link
Copy Markdown

New changes are detected. LGTM label has been removed.

@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

@Jdubrick

Jdubrick commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

/fs-review

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 1, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 2:09 PM UTC · Completed 2:23 PM UTC

Commit: 0b86b12 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Cost: $4.75

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

Low

  • [naming convention] workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/validation.ts:40 — 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). Consider renaming to hasMagicBytes or isMagicMatch.

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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[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.

@fullsend-ai-review fullsend-ai-review Bot added ready-for-merge All reviewers approved — ready to merge enhancement New feature or request labels Sep 1, 2026

@Jdubrick Jdubrick left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

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

Labels

enhancement New feature or request ready-for-merge All reviewers approved — ready to merge workspace/intelligent-assistant

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants