Offline Usage File: Support additional mime-types
Summary
Customer emailed their offline license usage CSV file to us, and received an automated message back that it could not be processed.
- Customer ticket (internal)
- subscription
- customer account
Full details of reported bug
I see that a cloud activation exists for the subscription, and the offline license is here.
Relevant logs and/or screenshots
The csv file itself is recorded in the logs here:
param[33]
specifically.
I also noticed these log entries from production.log
I, [2022-09-13T09:46:10.086326 #969237] INFO -- : [d94d5079-51c0-4d87-b445-4bb7ddc1f37f] Started POST "/rails/action_mailbox/mailgun/inbound_emails/mime" for 172.70.135.221 at 2022-09-13 09:46:10 +0000
I, [2022-09-13T09:46:10.088610 #969237] INFO -- : [d94d5079-51c0-4d87-b445-4bb7ddc1f37f] Processing by ActionMailbox::Ingresses::Mailgun::InboundEmailsController#create as */*
I, [2022-09-13T09:46:10.089279 #969237] INFO -- : [d94d5079-51c0-4d87-b445-4bb7ddc1f37f] Parameters: {"Accept-Language"=>"it-IT, en-US", ....... [snipped out]
I, [2022-09-13T09:46:10.520825 #969237] INFO -- : [d94d5079-51c0-4d87-b445-4bb7ddc1f37f] GCS Storage (385.1ms) Uploaded file to key: [snipped] (checksum: eOh6+mF+m4cU4kqmXYFa1g==)
I, [2022-09-13T09:46:10.522318 #969237] INFO -- : [d94d5079-51c0-4d87-b445-4bb7ddc1f37f] [ActiveJob] Enqueued ActionMailbox::RoutingJob (Job ID: f2d3a2bb-3291-4802-a2e7-b3321dd92c9b) to Sidekiq(default) with arguments: #<GlobalID:0x00007f8c54b5e798 @uri=#<URI::GID gid://payment-app/ActionMailbox::InboundEmail/30>>
I, [2022-09-13T09:46:10.532055 #969237] INFO -- : [d94d5079-51c0-4d87-b445-4bb7ddc1f37f] No template found for ActionMailbox::Ingresses::Mailgun::InboundEmailsController#create, rendering head :no_content
I, [2022-09-13T09:46:10.532353 #969237] INFO -- : [d94d5079-51c0-4d87-b445-4bb7ddc1f37f] Completed 204 No Content in 443ms (ActiveRecord: 19.1ms | Allocations: 25146)
I, [2022-09-13T09:46:10.537933 #969416] INFO -- : [ActiveJob] [ActionMailbox::RoutingJob] [f2d3a2bb-3291-4802-a2e7-b3321dd92c9b] Performing ActionMailbox::RoutingJob (Job ID: f2d3a2bb-3291-4802-a2e7-b3321dd92c9b) from Sidekiq(default) enqueued at 2022-09-13T09:46:10Z with arguments: #<GlobalID:0x000055749db261c0 @uri=#<URI::GID gid://payment-app/ActionMailbox::InboundEmail/30>>
I, [2022-09-13T09:46:10.630964 #969416] INFO -- : [ActiveJob] [ActionMailbox::RoutingJob] [f2d3a2bb-3291-4802-a2e7-b3321dd92c9b] ESC[36m GCS Storage (69.6ms) ESC[0mESC[34mDownloaded file from key: [snipped]ESC[0m
I, [2022-09-13T09:46:10.647535 #969416] INFO -- : [ActiveJob] [ActionMailbox::RoutingJob] [f2d3a2bb-3291-4802-a2e7-b3321dd92c9b] Rendered customer_mailer/provisioning_error_notification.html.haml within layouts/mailer (Duration: 4.6ms | Allocations: 3430)
Not sure how relevant it is, but this kinda stands out
No template found for ActionMailbox::Ingresses::Mailgun::InboundEmailsController#create, rendering head :no_content
Production's console output:
I, [2022-09-13T09:46:10.537933 #969416] INFO -- : [ActiveJob] [ActionMailbox::RoutingJob] [f2d3a2bb-3291-4802-a2e7-b3321dd92c9b] Performing ActionMailbox::RoutingJob (Job ID: f2d3a2bb-3291-4802-a2e7-b3321dd92c9b) from Sidekiq(default) enqueued at 2022-09-13T09:46:10Z with arguments: #<GlobalID:0x000055749db261c0 @uri=#<URI::GID gid://payment-app/ActionMailbox::InboundEmail/30>>
This log line indicates the ActionMailbox::InboundEmail
object saved from this email has id = 30
.
Using the steps from our troubleshooting docs, we can see the attached file has mime-type: 'application/octet-stream'
instead of the expected 'text/csv'
so we end up with an empty attachment which triggers a provisioning_error_notification.
Output from production
inbound_email = ActionMailbox::InboundEmail.find(30)
=> #<ActionMailbox::InboundEmail id: 30, status: "delivered", message_id: "VI1PR0701MB23836406448561E20F5820D2D5479@VI1PR0701...", ...>
mail = inbound_email.mail
=> #<Mail::Message:91420, Multipart: true, Headers: <Received: from ...>...>
license_usage_file = Array(mail.attachments).find do |attachment|
attachment.filename == 'license_usage.csv' && attachment.mime_type == 'text/csv'
end
=> nil
# Load all the attachments
attachments = Array(mail.attachments)
attachments.size
=> 2
attachment = attachments.last
=> #<Mail::Part:91460, Multipart: false, Headers: <Content-Type: application/octet-stream; name="license_usage.csv", ...>,
# the csv file is there and contains the usage data but the check for the mime_type doesn't succeed
Cause of Bug
In investigating this bug, it was determined that the mime-type mime-type: 'application/octet-stream'
used by the customer here is not currently supported by our code. This mime-type is somewhat common in email clients.
Proposal for Resolution
Consider the mime-type mime-type: 'application/octet-stream'
as part of the finding condition for offline usage data reporting.
Reported examples
- https://gitlab.zendesk.com/agent/tickets/325524
- https://gitlab.zendesk.com/agent/tickets/333322
- https://gitlab.zendesk.com/agent/tickets/335931
- https://gitlab.zendesk.com/agent/tickets/334735
- https://gitlab.zendesk.com/agent/tickets/339231
- https://gitlab.zendesk.com/agent/tickets/340432
-
https://gitlab.zendesk.com/agent/tickets/348986 (mime was
application/vnd.ms-excel
)