DeepSeek V4.1 Flash · 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
- 5
- Comments matching a bug
- 3
- Comments not matching
- 2
- Cost of this PR
- $0.133
Published comments (5)
Duplicate OptimizedImage.downsize breaks 5-argument emoji call — The 4-argument `downsize` at line 149 shadows the 5-argument version, so `Jobs::ResizeEmoji` calling it with 5 arguments will raise `ArgumentError` and custom emoji stop being downsized. Remove the dead definition and convert the emoji caller to a single `"100x100"` argument.
Animated GIF form uploads are downscaled to a static frame — `allow_animation` never matches because `downsize_instructions` tests the extensionless tempfile path, so animated GIFs collapse to a static frame. Pass the original `filename` into the downsize call as `app/models/upload.rb` already does.
Upload size validation ignores admin-configured max size settings — Hardcoding 10MB drops the `max_<type>_size_kb` lookup, so client-side validation no longer honors admin limits and `utilities-test.js.es6:52` can no longer trigger `file_too_large`. Keep the `Discourse.SiteSettings['max_' + type + '_size_kb']` lookup.
Oversized images not rejected after failed downsize attempts — A file still oversized after 5 passes is only rejected later by `Validators::UploadValidator#maximum_image_file_size`, wasting up to 5 conversions before the user sees an error. Derive the scale from `tempfile.size / SiteSetting.max_image_size_kb.kilobytes` and abort explicitly if it stays too large.
Oversized uploads run up to five ImageMagick passes — Each oversized upload runs up to five full ImageMagick cycles plus `ImageOptim` in `convert_with` (app/models/optimized_image.rb), multiplying CPU cost for large files. Resize once with a factor from the size ratio rather than iterating relative 80% steps.