AO3-7473 Possible to upload unusable collection/skin icon - #5825
AO3-7473 Possible to upload unusable collection/skin icon#5825cinderbrick1212 wants to merge 0 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR prevents 500 errors during Skin/Collection icon processing by restricting icon uploads to raster image MIME types that the resizing pipeline can safely handle (GIF/JPEG/PNG), matching the existing Pseud icon validation approach.
Changes:
- Tightened
Skiniconallowed_formatsfrom anyimage/*MIME type toimage/gif,image/jpeg, andimage/png. - Tightened
Collectioniconallowed_formatsfrom anyimage/*MIME type toimage/gif,image/jpeg, andimage/png.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| app/models/skin.rb | Restricts Skin icon MIME types to GIF/JPEG/PNG to avoid unsupported formats causing processing errors. |
| app/models/collection.rb | Restricts Collection icon MIME types to GIF/JPEG/PNG to avoid unsupported formats causing processing errors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| validates :icon, attachment: { | ||
| allowed_formats: %r{image/\S+}, | ||
| allowed_formats: %w[image/gif image/jpeg image/png], | ||
| maximum_size: ArchiveConfig.ICON_SIZE_KB_MAX.kilobytes | ||
| } |
| validates :icon, attachment: { | ||
| allowed_formats: %r{image/\S+}, | ||
| allowed_formats: %w[image/gif image/jpeg image/png], | ||
| maximum_size: ArchiveConfig.ICON_SIZE_KB_MAX.kilobytes | ||
| } |
|
Hi, Anish Kapoor! Thank you so much for this pull request. Someone will be along to review it soon. (Just as a heads up, we don't generally allow the use of AI, and Copilot reviews should be disabled for this project.) In the meantime, we've updated the Jira issue status to In Review so no one mistakenly creates a duplicate pull request. If you'd like the ability to comment on, assign, and transition issues in the future, you're welcome to create a Jira account! It makes things a bit easier for us on the organizational side if the Full Name on your Jira account either closely matches the name you'd like us to credit in the release notes or includes it in parentheses, e.g. "Nickname (CREDIT NAME)." Once you've done that (or if you've already done it -- Jira has been unreliable about showing us new accounts in the admin panel lately), you can either reply here or send an email to otw-coders@transformativeworks.org with your account name and email address and we'll set up the permissions for you. Thanks again for contributing! If you have any questions, you can contact us at the same email address listed above. |
brianjaustin
left a comment
There was a problem hiding this comment.
Thanks for the PR! Could you add some automated tests to ensure that indeed non-supported types are rejected?
Understood! Copilot is now disabled, and I've just emailed you my Jira account info. Thanks for your help! |
…de#5825) The config exists at the model/resource class from the registerable module, but it was not being honored, instead we were directly relying on the main Devise config. Now this can be configured and honored per-model/resource class, as expected. This is similar to otwcode#5429 and `sign_in_after_reset_password` fix.
Pull Request Checklist
as the first thing in your pull request title (e.g.
AO3-7473 Fix 500 error on Skin and Collection icon uploads)until they are reviewed and merged before creating new pull requests.
Issue
https://otwarchive.atlassian.net/browse/AO3-7473
Purpose
I updated the allowed image formats for Skin and Collection icons to prevent 500 errors.
Previously, the validation accepted any
image/*MIME type, which caused server crashes when the image processing library attempted to resize unsupported vector formats like SVGs. I updatedapp/models/skin.rbandapp/models/collection.rbto strictly allowimage/gif,image/jpeg, andimage/png, mirroring the safer validation that is already in place forPseudicons.Testing Instructions
.svgfile (or another unsupported image format) as the icon and submit the form..png,.jpg, or.gifto ensure standard uploads still process correctly for both models.Credit
Anish Kapoor (he/him)