Repository navigation
fix(avatars): return 404 for unsupported favicon raster bytes - #15070
Conversation
…_found Introduce UnsupportedFormatException in utopia-php/image and catch it when building a favicon preview from PNG/JPEG link targets so invalid bodies return 404 instead of 500. Add mock fixtures and an e2e regression. Fixes CLOUD-3QWG Co-authored-by: Chirag Aggarwal <[email protected]>
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
The change replaces generic
Reviewed commit: bb83c93 |
🟢 Tier S · Ready to merge
The image package now exposes a dedicated exception for unsupported image signatures, and the favicon endpoint maps unsupported or undecodable raster icon bodies to
📂 Walkthrough · 8
Reviewed |
There was a problem hiding this comment.
This PR adds a dedicated UnsupportedFormatException to the image library, updates tests, and maps non-image favicons in the Avatars favicon endpoint to a 404 AVATAR_ICON_NOT_FOUND, backed by new mock endpoints and an e2e test.
Key findings
- 🟡 Catch misses
ImagickExceptionon corrupt favicon decode — Get.php:199
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Fix Pint import order, PHPStan @throws on Image constructor, catch ImagickException when favicon raster bytes fail to decode, and add e2e coverage for truncated PNG favicon bytes.
The findings that requested changes are resolved. See the summary comment for what is still open.
The findings that requested changes are resolved. See the summary comment for what is still open.
|
@hansi-codes review |
Summary
mainthat/v1/avatars/faviconstill letsUtopia\Image\Format::detect()failures bubble up as 500 when a linked PNG/JPEG favicon body is not a supported raster image (CLOUD-3QWG).Utopia\Image\Exception\UnsupportedFormatExceptionand throw it fromFormat::detect()instead of a generic exception.Imageconstruction to mapUnsupportedFormatExceptiontoavatar_icon_not_found(404), matching the intent ofAvatars/Http/Image/Get.testGetFaviconUnsupportedRasterIconto assert 404 +avatar_icon_not_foundinstead of 500.Fixes CLOUD-3QWG
Test plan
bin/monorepo test imagedocker compose exec appwrite test tests/e2e/Services/Avatars --filter=testGetFaviconUnsupportedRasterIconRelated: appwrite-labs/cloud#5938