Amazon Ergo 1.0 · 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
- 4 of 9
- Comments published
- 5
- Comments matching a bug
- 4
- Comments not matching
- 1
- Cost of this PR
- $2.304
Published comments (5)
Upload validation ignores configured size limits — The hardcoded `10 * 1024` cap ignores `Discourse.SiteSettings['max_' + type + '_size_kb']`, blocking sites that allow larger files and letting files over smaller configured limits upload before server rejection; `test/javascripts/lib/utilities-test.js.es6` also fails. Restore the site-setting lookup here and in the 413 handler.
Animated GIF resizing passes percentage geometry to gifsicle — With `allow_animated_thumbnails` enabled, large animated GIFs cannot be uploaded: `downsize_instructions_animated` passes `80%` to `gifsicle --resize-fit`, which expects pixel geometry, so the loop exhausts its attempts and `Validators::UploadValidator` rejects the oversized file. Use computed pixel dimensions or `--scale`.
downsize no longer accepts width and height arguments — Custom emoji images are never resized: `app/jobs/regular/resize_emoji.rb` still calls `OptimizedImage.downsize` with five arguments, raising `ArgumentError` and accumulating failed jobs. Pass a dimensions string such as `100x100` or preserve the old signature.
Large animated GIFs are flattened when downsized — Animated GIFs over `max_image_size_kb` lose all but their first frame because `OptimizedImage.downsize` receives an extensionless Rack tempfile path, so `optimize` misses `downsize_instructions_animated`. Pass the original filename/extension or detect animation from file content so the animated branch runs.
Downsize loop can still upload images over the size limit — Five `80%` passes can leave an image above `max_image_size_kb`, and ignoring `OptimizedImage.downsize` failures wastes attempts before `Upload.create_for` stores an oversized file. Check `tempfile.size` after the loop and return an error or use a fallback; stop retrying when `OptimizedImage.downsize` returns false.