Claude Opus 5.5 · Balanced
feature-automatically-downsize-large-images-discourse-cursor
Discourse · Ruby · S · 30–99 lines · 3 files
The normal review, with one generalist agent. Judge: Claude Haiku 5.5.
- Gold bugs found
- 3 of 8
- Comments published
- 4
- Comments matching a bug
- 3
- Comments not matching
- 1
- Cost of this PR
- $0.571
Published comments (4)
Second `downsize` definition overrides the width/height variant — `Jobs::ResizeEmoji` still calls `OptimizedImage.downsize(path, path, 100, 100, opts)`, which now raises `ArgumentError` and breaks emoji resizing. Ruby has no overloading, so rename one method (e.g. `downsize_to_dimensions`) or keep a single `downsize` that builds the dimensions string from width and height.
Animated GIF downsize passes a percentage gifsicle rejects and retries after failure — gifsicle likely rejects the `--resize-fit 80%` from `downsize_instructions_animated`, so animated GIFs never shrink and the loop spawns five failing processes. Pass pixel dimensions on the animated path and break the loop when `downsize` returns `false`.
Fixed 10MB upload limit ignores configured max image/attachment sizes — Attachments over `max_attachment_size_kb` pass this check and fail only on the server, while images an admin allowed above 10MB are wrongly rejected. Apply the 10MB floor only to images, e.g. `max(max_image_size_kb, 10MB)`, and keep `Discourse.SiteSettings['max_' + type + '_size_kb']` for attachments.
Oversized images are decoded by ImageMagick without a pixel-dimension check — A small, highly compressed file with huge pixel dimensions can exhaust server CPU and memory across up to 5 `downsize` passes, and in synchronous API mode this runs inside the request. Check pixel dimensions with `FastImage` before calling `downsize` and reject oversized images, or cap `convert` with `-limit`.