-
Notifications
You must be signed in to change notification settings - Fork 21.9k
Cannot deliver new inbound email via form #44008
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
Conversation
Thanks for this. Could you please add a test to prevent regressions? It would go here https://github.com/rails/rails/blob/main/actionmailbox/test/controllers/rails/action_mailbox/inbound_emails_controller_test.rb |
@ghiculescu I added an empty string as part of the attachments collection in the test that exercises attachments, aiming to copy the behavior we see when submitting the form via a browser. Let me know whether you'd rather have a new test case for this or just updating an existing test case is fine. Thank you! |
Looks good to me, as long as the test would fail without the fix. |
Test failed, I was unable to run the test locally (m1 hell) couldn't install the mysql2 gem. I'll try setting up a virtual host and check again. |
Minor update: All attachments are casted to strings whenever I add an empty string to the attachments array. This is not the case via the browser, when I upload an attachment I can see that the elements inside the attachments array are not casted to strings (this is from the web console in the error page)
However, when using
|
@ghiculescu Here's why #44008 (comment) I couldn't make the test work for that particular scenario. So, for simplicity I ended up moving this test to another scenario that wasn't using attachments at all. Test fails without the change and passes with it. Let me know what you think, happy to help. |
@juanmanuelramallo could you squash your commits? |
Fixes #43928. |
1. Install ActionMailbox in your app 2. Visit `/rails/conductor/action_mailbox/inbound_emails` as specified in here https://guides.rubyonrails.org/action_mailbox_basics.html#working-with-action-mailbox-in-development 3. Click on "New inbound email by form" 4. Fill the form and submit The inbound email is created successfully A `NoMethodError` is raised: ``` NoMethodError in Rails::Conductor::ActionMailbox::InboundEmailsController#create undefined method `original_filename' for "":String ``` ``` >> mail_params[:attachments] => [""] ``` This happens because of the hidden field tag the multiple select field uses under the hood. An easy fix for this problem is to exclude the empty string from the collection. Add empty string in attachments params in test file Updated an existing test case to include an empty string in the attachments collection, mimicking the behavior of the form submission. Update inbound emails controller test Moved the empty string for attachments to a different test case where attachments are not actually sent, just so that we can exercise that this test fails without this change and passes with it.
721c3dd
to
4b5c2d4
Compare
@ghiculescu rebased with latest main and squashed all commits |
Is this PR something that will go into a Rails 7.0.X patch or held off for Rails 7.1 later this year/next year? Sorry to ask rails release question in the ticket. |
Closing this as it is already solved via #45103 |
Summary
Steps to reproduce
/rails/conductor/action_mailbox/inbound_emails
as specified in here https://guides.rubyonrails.org/action_mailbox_basics.html#working-with-action-mailbox-in-developmentExpected
The inbound email is created successfully
Actual
A
NoMethodError
is raised:Other Information
This happens because of the hidden field tag the multiple select field uses under the hood. An easy fix for this problem is to exclude the empty string from the collection.