DeepSeek V4 Pro · Heavy

feature-automatically-downsize-large-images-discourse-cursor

Discourse · Ruby · S · 30–99 lines · 3 files

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Opus 5.5.

Gold bugs found
3 of 9
Comments published
3
Comments matching a bug
3
Comments not matching
0
Cost of this PR
$1.072

Published comments (3)

highbugapp/models/optimized_image.rb:149-151

OptimizedImage.downsize signature breaks Jobs::ResizeEmoji calls — Every time an admin uploads a custom emoji, `resize_emoji.rb:14` still calls this with five positional args, so Ruby raises `ArgumentError` and the emoji is never resized. Update `resize_emoji.rb` to pass a single dimension string such as `"100x100"` instead of `100, 100`.

mediumbugapp/assets/javascripts/discourse/lib/utilities.js:180-185

validateUploadedFile hardcodes 10 MB limit, ignoring max_attachment_size_kb — Non-image attachments are never downsized server-side, so admins' `max_attachment_size_kb` is silently dropped on the client and files up to 10 MB pass validation only to be rejected later. Keep the site setting for non-image types and use 10 MB only for images.

mediumbugapp/controllers/uploads_controller.rb:67

Animated GIF uploads lose animation when downsized due to temp path — `OptimizedImage.optimize` only selects the animated path when the source path has a `.gif` extension, but `tempfile.path` does not reliably preserve the original suffix. Use a tempfile with a `.gif` suffix before calling `downsize`, or change `optimize` to select the animated path from `filename` or the content type rather than from `tempfile.path`.

Gold bugs found (3)

highdownsize is defined twice in OptimizedImage; the new (from, to, dimensions, opts) version overrides the (max_width, max_height) one, so existing callers such as ResizeEmoji that pass width and height now raise ArgumentError.
highThe client-side upload size check hardcodes 10 MB instead of the per-type max_<type>_size_kb setting, so attachment limits diverge from the server: larger allowed attachments are blocked and smaller limits are only enforced server-side.
mediumAuto-downsizing passes the upload tempfile path, which lacks a .gif extension, so the animated branch is never chosen and convert keeps only the first frame, flattening oversized animated GIFs.

Gold bugs missed (6)

highThe upload downsizing passes a percentage ('80%') as dimensions, but for animated GIFs the gifsicle path uses --resize-fit, which expects WxH geometry, so downsizing silently fails.
highClaims the downsize loop checking tempfile.size may never terminate because of a stale cached size, causing infinite loops.
highOversized SVG uploads go through the new ImageMagick downsize loop because SVG counts as an image, so the vector file is rasterized or corrupted in place before Upload.create_for parses it as SVG.
criticalThe upload tempfile path, which for API URL uploads embeds the request-controlled type param, is now passed to OptimizedImage.downsize and run unescaped in a shell via backticks, allowing command injection through type.
mediumThe 413 upload error message states a hard-coded 10 MB maximum that may not match the limit the server or web server actually enforces.
mediumThe oversized-image downsize loop in UploadsController#create always uses allow_animated_thumbnails as the animation policy, so with allow_animated_avatars on and allow_animated_thumbnails off an oversized animated GIF avatar is reduced to its first frame before Upload.create_for applies the avatar setting, losing the animation.