Closed jamgregory closed 5 years ago
I'm sorry, but this seems like a fix for your local problems. I don't think it is Brimir's responsibility to work around misconfigured systems. No other users have reported these issues, so I'm declining this.
I don't think it's an issue with our system being misconfiguration per se - many PDF attachments are accepted, but we've seen a number failing recently due to the thumbnail generation.
Alternatively, would you be happy for me to submit a PR that has a setting to disablebthumbnail generation which I think would fix this issue for us (we don't use thumbnails in Brimir)?
What is the failure? What is reported in the Rails logs?
For one of the attachments, we get the following recorded in the logs (this is running on my dev machine):
[snip ... ticket insertion process ... snip]
[paperclip] Trying to link /tmp/256e2dc2a382108383ca88fd4ec6b50720181206-6942-xe4miq.pdf to /tmp/c431d9fa8f33b8cd429659ddef6da64d20181206-6942-r8jj88.pdf
Command :: file -b --mime '/tmp/c431d9fa8f33b8cd429659ddef6da64d20181206-6942-r8jj88.pdf'
Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/256e2dc2a382108383ca88fd4ec6b50720181206-6942-xe4miq.pdf[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
[paperclip] Trying to link /tmp/256e2dc2a382108383ca88fd4ec6b50720181206-6942-xe4miq.pdf to /tmp/c431d9fa8f33b8cd429659ddef6da64d20181206-6942-uzx0og.pdf
Command :: file -b --mime '/tmp/c431d9fa8f33b8cd429659ddef6da64d20181206-6942-uzx0og.pdf'
[snip ... email content ... snip]
[paperclip] Trying to link /tmp/256e2dc2a382108383ca88fd4ec6b50720181206-6942-xe4miq.pdf to /tmp/c431d9fa8f33b8cd429659ddef6da64d20181206-6942-1hcefnd.pdf
Command :: file -b --mime '/tmp/c431d9fa8f33b8cd429659ddef6da64d20181206-6942-1hcefnd.pdf'
Completed 422 Unprocessable Entity in 664ms (Views: 0.7ms | ActiveRecord: 15.6ms)
For the other attachment, the following happens:
[snip ... ticket insertion process ... snip]
(0.1ms) begin transaction
[paperclip] Trying to link /tmp/fa52d54d2e721a860586d4ee77dd5bb620181206-6942-66fk80.PDF to /tmp/fa52d54d2e721a860586d4ee77dd5bb620181206-6942-1c3gy8q.PDF
Command :: file -b --mime '/tmp/fa52d54d2e721a860586d4ee77dd5bb620181206-6942-1c3gy8q.PDF'
Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/fa52d54d2e721a860586d4ee77dd5bb620181206-6942-66fk80.PDF[0]' 2>/dev/null
(0.1ms) rollback transaction
[snip ... email content ... snip]
Completed 500 Internal Server Error in 252ms (ActiveRecord: 15.1ms)
FloatDomainError (NaN):
app/mailers/ticket_mailer.rb:156:in `block in receive'
app/mailers/ticket_mailer.rb:138:in `each'
app/mailers/ticket_mailer.rb:138:in `receive'
app/controllers/tickets_controller.rb:185:in `create'
At the point where I remove the thumbnail functionality for PDFs, it appears to resolve this issue. I believe it's an incompatibility with ImageMagick or Ghostscript and the PDFs that have been generated (at least one of them appears to have been created by Word 2013). We haven't really had this issue before, but have had quite of lot of failing attachments due to the above issues in the last week.
What happens if you manually run identify -format '%wx%h,%[exif:orientation]' your.pdf
?
For one of the PDFs, it (appears to) correctly returns the details requested:
595x842,
For the other, the following error is returned:
**** Error: Spurious '>>' after 'endstream' ignored.
Output may be incorrect.
The above suggests to me it is a problem with the PDF generation (the metadata doesn't suggest what it was generated with though).
Well, I've never had any problems with imagemagick not recognizing pdf's, we use it in lots of other projects, but let's just merge it.
Thanks @frenkel, much appreciated :+1:
We've had a few issues recently when Paperclip has failed to create attachments for incoming emails due to a number of issues. These appear to be centred around the way it creates thumbnails, and potential issues with ImageMagick/Ghostscript.
The changes proposed here try to gracefully fall back from creating an attachment if thumbnail generation fails, so that the email is still received but without the thumbnail.
This issue may go away if the application is switched to Active Storage when it is upgraded to Rails 5.2.