Claude Opus 5.5 · 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 Haiku 5.5.

Gold bugs found
3 of 8
Comments published
5
Comments matching a bug
3
Comments not matching
2
Cost of this PR
$1.680

Published comments (5)

highbugapp/assets/javascripts/discourse/lib/utilities.js:181-185

Hardcoded 10MB upload limit ignores configured max_<type>_size_kb settings — Sites whose `max_<type>_size_kb` exceeds 10MB now have valid uploads rejected in the browser, while attachments between the setting and 10MB upload in full only to fail on the server. Use the larger of 10MB and the setting for images, and `Discourse.SiteSettings['max_' + type + '_size_kb']` as-is for attachments.

highbugapp/controllers/uploads_controller.rb:66-68

Animated GIF downsize passes "80%" to gifsicle --resize-fit, which needs WxH — Animated GIFs go to `resize_instructions_animated` in `optimized_image.rb`, which builds `gifsicle --resize-fit 80%`, but `--resize-fit` only accepts WxH, so the command fails and every attempt is wasted. Pass explicit WxH `dimensions` computed from the image size, or use gifsicle's `--scale 0.8` on the animated path.

highbugapp/models/optimized_image.rb:145-151

Second `downsize` definition overrides the width/height variant — Ruby has no overloading, so this replaces the width/height form, and the 5-argument `OptimizedImage.downsize` call in `app/jobs/regular/resize_emoji.rb` now raises `ArgumentError`, breaking emoji resizing. Rename the dimensions-string variant or have `ResizeEmoji` pass `"100x100"`.

mediumperformanceapp/controllers/uploads_controller.rb:64-70

Upload request runs up to 5 synchronous image downsizes in a row — Up to 5 `convert` and ImageOptim passes on a 10MB file tie up a web worker for seconds, so a few large uploads can exhaust the CPU and worker pool. Pick one scale from the size ratio and call `OptimizedImage.downsize` once, or move downsizing to a background job.

mediumbugapp/assets/javascripts/discourse/lib/utilities.js:182-184

Attachment size limit hardcoded to 10 MB instead of the server's site setting — The server still caps attachments at `SiteSetting.max_attachment_size_kb`, so the `file_too_large` alert advertises a 10240 KB limit the server will reject. Keep reading `Discourse.SiteSettings['max_' + type + '_size_kb']` for non-image types so the shown limit matches the enforced one.

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

Gold bugs missed (5)

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