GLM-5.3 Flash · 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
- 5
- Comments matching a bug
- 3
- Comments not matching
- 2
- Cost of this PR
- $0.292
Published comments (5)
Over-limit image stored when OptimizedImage.downsize fails or makes no progress — When the convert subprocess fails, `tempfile.size` never shrinks, so the command runs five times and the oversized image is still stored since `Upload.create_for` never revalidates the limit. Check the `OptimizedImage.downsize` return value and fail the upload when no progress is made.
4-arg downsize overrides 5-arg version, breaking ResizeEmoji caller — `app/jobs/regular/resize_emoji.rb` still calls the old 5-argument form, so every emoji resize now raises an `ArgumentError` and the background job fails. Make `downsize` accept both signatures or update that caller.
Animated GIFs flattened by downsize since tempfile path lacks file extension — The extensionless Rack tempfile path means `OptimizedImage.optimize` never takes the animated branch and its `convert` keeps only the first frame, silently flattening oversized GIFs. Copy the upload into a `Tempfile` carrying the filename's extension before downsizing.
Downsize loop runs all 5 attempts even when convert fails or file shrinks — A failed convert leaves the file unchanged, so all five synchronous `OptimizedImage.downsize` calls still execute in the request thread and can pin workers or exhaust CPU under concurrent uploads. Break out of the loop when `tempfile.size` stops shrinking.
Hardcoded 10MB client limit ignores per-type site settings — On sites with a smaller configured limit, non-image files under 10MB pass client validation, consume upload bandwidth, and are then rejected by the server citing a different limit. Keep reading `Discourse.SiteSettings['max_' + type + '_size_kb']` instead of hardcoding it.