Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActiveStorage::TransformJob doesn't accept previewable files #50005

Closed
nicowenterodt opened this issue Nov 10, 2023 · 0 comments · Fixed by #50006
Closed

ActiveStorage::TransformJob doesn't accept previewable files #50005

nicowenterodt opened this issue Nov 10, 2023 · 0 comments · Fixed by #50006

Comments

@nicowenterodt
Copy link
Contributor

Steps to reproduce

When having a predefined variant for an attachment and you're making use of the preprocessed option, the ActiveStorage::TransformJob will fail for previewable files like PDFs with ActiveStorage::InvariableError.

To reproduce simply define a variant for an attachment like this:

has_one_attached :file do |attachable|
    attachable.variant :thumb, resize_to_limit: [400, 600], preprocessed: true
end

After uploading a PDF the ActiveStorage::TransformJob will be enqeued. As soon as the job is being processed it fails with ActiveStorage::InvariableError.

Expected behavior

The ActiveStorage::TransformJob should accept previewable files as well so preprocessed variants are also possible for PDF documents and other previewable filetypes.

Actual behavior

The ActiveStorage::TransformJob fails when a previewable blob is being processed with ActiveStorage::InvariableError

System configuration

Rails version: 7.1.1

Ruby version: 3.2.2

nicowenterodt added a commit to nicowenterodt/rails that referenced this issue Nov 10, 2023
The transform_job crahes if you want to preprocess a previewable files.
This commit fixes that by checking whether the blob is previewable or not and using the appropriate method.
nicowenterodt added a commit to nicowenterodt/rails that referenced this issue Nov 11, 2023
This commit applies the suggestions which occurred during review.
- use blobs `representation` method to process variants or previews
- more clear changelog entry
- harmonize test case with existing one

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
jonathanhefner added a commit to nicowenterodt/rails that referenced this issue Nov 11, 2023
The transform_job crahes if you want to preprocess a previewable files.
This commit fixes that by using the blob's `representation` method to
process variants or previews.

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
jonathanhefner added a commit that referenced this issue Nov 11, 2023
Fix #50005 transform_job not accepting previewables
jonathanhefner added a commit that referenced this issue Nov 11, 2023
Fix #50005 transform_job not accepting previewables

(cherry picked from commit 17c82c6)
catlee pushed a commit to Shopify/rails that referenced this issue Dec 4, 2023
The transform_job crahes if you want to preprocess a previewable files.
This commit fixes that by using the blob's `representation` method to
process variants or previews.

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants