Don't push the entire original email into Redis for sending a rejection e-mail
In gitlab-com/gl-infra&490 (closed) we've started compressing and limiting the payload size for Sidekiq jobs.
In This Sentry event we've received an email with an attachment that was already compressed. The e-mail was rejected, which in turn results in us replying to the email with the result another Sidekiq job through EmailRejectionMailer.rejection.deliver_later
.
Because of the .deliver_later
we store the entire email in Redis (again). Because the email contained a zip file that was likely already compressed, it did not compress well and exceeded the 5MB limit, we rejected the job and raised an exception.
The email we're trying to send in response only needs a handful of attributes from the original email:
.from
.to.first
.message_id
.subject
Can we limit the attributes passed into the email to those? Or at least strip large attachments?