Skip to content

fix(feedback): sanitize screenshot metadata, compress captures, and fall back without screenshot - #1970

Merged
callumalpass merged 2 commits into
mainfrom
fix/feedback-screenshot-validation
Nov 26, 2026
Merged

callumalpass merged 2 commits into
mainfrom
fix/feedback-screenshot-validation

Conversation

@callumalpass

Copy link
Copy Markdown
Member

Summary

Fixes feedback submission failures (The screenshot is invalid or too large.) when sending screenshots captured or marked up on high-DPI displays or browsers that emit standard image metadata chunks/segments.

Root cause

  • The feedback Worker rejected any PNG containing eXIf, iTXt, tEXt, or zTXt chunks and any JPEG containing APP1 (EXIF/XMP), APP2 (ICC color profile), APP13 (IPTC), or COM segments. macOS/WebKit and high-DPI canvas exports legitimately include metadata chunks and Display P3 ICC profiles.
  • Client-side screenshotFromCanvas only encoded PNG at full canvas resolution without compressing or downscaling to fit the 3 MB attachment limit, FeedbackMarkup always re-encoded as PNG even for JPEG sources, and readFeedbackScreenshot rejected uploads above 3 MB upfront instead of scaling them down.
  • Any screenshot validation error (400 invalid_screenshot or 413 payload_too_large) blocked the feedback message from being delivered.

Changes

  • services/feedback/src/index.ts:
    • Strip PNG metadata chunks (eXIf, iTXt, tEXt, zTXt, iDOT) and JPEG EXIF/IPTC/comment segments (0xe1, 0xed, 0xfe) instead of rejecting otherwise valid images; preserve JPEG ICC color profiles (0xe2) and require PNG IDAT.
    • Return invalid_screenshot (rather than invalid_field) when content_base64 exceeds the base64 length cap.
  • packages/app-ui/src/feedback-data.ts, FeedbackMarkup.tsx, Feedback.tsx:
    • Strip browser-emitted PNG/JPEG metadata client-side after canvas export.
    • Compress/downscale oversized canvas exports to JPEG across progressive dimension/quality steps so high-DPI captures and marked-up screenshots fit under the 3 MB limit; allow uploads up to 20 MB and scale them down to 2560 px max edge before encoding.
    • Preserve screenshot.media_type when saving markup in FeedbackMarkup.
    • Classify screenshot rejection errors (invalid_screenshot, payload_too_large, HTTP 413) and automatically resend the feedback text without the screenshot (reusing the unspent Turnstile token because server validation runs before Turnstile verification), informing the user clearly.
    • Update all @mdbase-dev/ui locale catalogues (en, de, es, fr, it, ja, ko, pt, ru, zh).
  • Tests & changelog:
    • Added worker tests for PNG chunk stripping, JPEG ICC preservation + EXIF/COM stripping, and oversized base64 classification (services/feedback/src/index.test.ts).
    • Added @mdbase-dev/ui tests for metadata stripping, downscaled JPEG fallback, and screenshot error classification (packages/app-ui/src/feedback.test.ts).
    • Added portal integration test for automatic text-only fallback on invalid_screenshot (apps/portal/src/FeedbackPage.test.tsx).
    • Added changelog.d/fix-feedback-screenshot-validation.md.

Verification

  • rpnpm run i18n:check
  • rpnpm run check:changelog
  • rpnpm run check:architecture
  • rpnpm run build:packages
  • rpnpm --filter @mdbase/feedback-worker run typecheck && test
  • rpnpm --filter @mdbase-dev/ui run typecheck && test src/feedback.test.ts
  • rpnpm --filter @mdbase/connect-portal run typecheck && test src/FeedbackPage.test.tsx

@callumalpass
callumalpass marked this pull request as ready for review November 26, 2026 21:54
@callumalpass
callumalpass added this pull request to the merge queue Nov 26, 2026
@callumalpass
callumalpass removed this pull request from the merge queue due to a manual request Nov 26, 2026
@callumalpass
callumalpass added this pull request to the merge queue Nov 26, 2026
Merged via the queue into main with commit abecc90 Nov 26, 2026
35 checks passed
@callumalpass
callumalpass deleted the fix/feedback-screenshot-validation branch November 26, 2026 22:55
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.

1 participant