-
Notifications
You must be signed in to change notification settings - Fork 285
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
Invalid image file when using Active Storage and Action Mailbox Inbound Emails #555
Comments
@estebanutz , thank you for reporting the issue, it should be fixed in the latest version: 2.1.2 |
@const-cloudinary, Thanks! The issue has been fixed. I have another quick question for you, and I don't know if this is related to this closed issue. When testing Action Mailbox inbound emails, when using Cloudinary when trying to process or read the email, for example getting the email "from" and "to" info I get nothing. When I switch to local as a service, same inbound email, I get everything from, to, body, etc. Could it be an ActiveStorage issue? I checked the blob information for both emails and files; they contain the same information. Any ideas? |
@estebanutz, it would be great if you could provide some sample code that I would be able to check |
@const-cloudinary sure, there is little code since I'm using the conductor controller to run those tests. Same rails app as above: config/environments/development.rb app/mailboxes/application_mailbox.rb
app/mailboxes/articles_mailbox.rb
So, in the logger output, all that is empty, and also, if for example, you view the "Full email source" in one of your emails: /rails/conductor/action_mailbox/inbound_emails/ID it's empty as well. When you change the active_storage.service to :local you get all the correct values: I hope that helps, thanks! |
Hi @const-cloudinary any updates on this issue? Any other way I can help? Thanks! |
Hi @estebanutz, Thank you for bringing this to our attention. We have investigated the issue and were able to reproduce it in our development environment, where incomplete class reloading resulted in broken links. This issue has been addressed in version 2.2.0. Please try updating to this version and let us know if it resolves your issue. |
@const-cloudinary I tried it, and now it sort of works. It's very inconsistent, and I've been troubleshooting it for a while and I can't say for sure what it is, but in my code above:
If I start testing multiple inbound emails, for example, let's say I send 10 emails. The first 4 emails will return the correct information and then the rest won't have anything, so mail.from, or mail.to or mail.decoded return all empty. I thought maybe it had something to do with the email service (Postmark) so I tried Mailgun, same inconsistent behavior. Any ideas what could be happening? |
@estebanutz
Specifically would pay attention on: If all files are OK, would continue to check Rails, it does perform all kind of lazy loading things, maybe something is not in-sync, or need to trigger some initialization explicitly. |
@cloudinary-bot Ok, let me check on that and report back, thanks! |
@const-cloudinary following your suggestion I checked the rails logs and ran a couple of test emails, and I'm getting the same results you showed above, for example:
One interesting thing I found is that if I look at the files uploaded under the media library in Cloudinary, the files that contain no information when trying to read "mail.from" or "mail.decoded", etc. have an N/A format. The emails that I can actually pull information from show EML as the format. Another way to test this is if you go directly in a browser to the generated URL, the N/A ones will say something like: "No webpage was found for the web address". The ones with EML format will prompt you to download the file. |
@estebanutz , unfortunately I cannot reproduce it on my side, I suspect it loses file extension (.eml) during upload for some reason, to investigate it, can you please install the gem from this branch? Add the following line to your Gemfile: And rerun it. In the log you should see something like:
Then you can compare it with the url that gets generated:
(you can ignore version part |
I get the error message below when trying to update the gem. Should I just use 'cloudinary' only (remove _gem)?
If so I tried it and I'm not getting the (filename: message.eml) part, here's what I'm getting:
|
@const-cloudinary another piece of information that may be helpful for you is that when sidekiq is processing the background jobs the logs are as follow: 'Headers' is not empty
vs empty:
|
@const-cloudinary I keep troubleshooting this issue. I pushed the site to a test server for more testing and got the same inconsistent results. Could it be that, in some cases, there is a delay between when ActiveStorage fully downloads the file and when ActionMailbox processes it, resulting in errors? |
@estebanutz , there should be no significant delays, unless you attach really large files to your emails. Another thing I would try, is to set something like:
This will force all uploads to be treated as raw files. |
@const-cloudinary I have not done any tests with attachments, all my tests are just plain text. I mentioned delayed because it looked to me that ActionMailbox was running before the email was downloaded, so it had no information about the email's content. I'll try and test with My workaround to make this work, which I think is overkill, is to run a background job that waits 5 seconds and sends the inbound email ID. Then, I can process the inbound email just fine. |
Describe the bug in a sentence or two.
In my app I've setup Action Mailbox, which uses Active Storage to store the content of the inbound emails. I've integrated Cloudinary gem just fine with Active Storage with the rest of the app, but now I'm getting a "ActiveStorage::IntegrityError in Rails::Conductor::ActionMailbox::InboundEmailsController#create Invalid image file" "Exception Causes
CloudinaryException: Invalid image file" when testing inbound emails.
I can see in the active_storage_blobs table that the emails content_type as "message/rfc822". I read somewhere that Active Storage is sending the email info to Cloudinary as an image for some reason, but I could be wrong.
What am I missing? Any help would be greatly appreciated! Also, should this issue be posted in the Rails repo? Thanks!
Issue Type (Can be multiple)
Integration with Active Storage and Action Mailbox
Operating System
Environment and Libraries (fill in the version numbers)
The text was updated successfully, but these errors were encountered: