View Issue Details

IDProjectCategoryView StatusLast Update
0029148Plugin - EmailReportingGeneralpublic2021-11-11 12:14
Reporterjensberke Assigned ToSL-Gundam  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Product Version0.10.1 
Summary0029148: Attachments with long filenames crash the import and new tickets for the same email weill be created in an endless loop
Description

Column "filename" in "mantis_bug_file_table" has, as some other columns in this table, a limit of 250 characters. An email containing an attachment with a file name longer than this will caused the following error:

Database query failed. Error received from database was #1406: Data too long for column 'filename' at row 1 for the query: INSERT INTO mantis_bug_file_table
( bug_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, user_id, bugnote_id, content )
VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ).

The result of this is the following situation:
The ticket has been created successfully.
The attachment has not been added to the ticket.
The email will stay on the mail server.

And this results in an endless loop: the next time EmailReport is started, the email is fetched again, a new ticket is created again and the attachment causes the error again.

Steps To Reproduce

Create a file with more than 250 characters, e.g. the following one, which has 255 characters:

12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901.txt

Attach the file to an email, send it to the email address configured in the EmailReporting plugin and the error will occur.

A real-life use-case where a too long file name causes this error is this one:

I receive an email from someone with a subject containing more than 250 characters.
I forward the email to the email address used for the EmailReporting plugin and my email client attaches the contents of the original email as an attachment using the filename "[VERY LONG SUBJECT].eml".
EmailReporting fetches the email, creates the ticket, tries to import this attachment and results in the error mentioned above.

Additional Information

The Mantis core also doesn't deal with this error yet, which I reported as 0029144.

Two ideas for a solution:

1.
Deal with this error only:
Truncate the file names (probably using a function of the mantis API if there is one) and make the truncated file name unique across all attachments of the email that's being parsed.

2.
Prevent loops like this in general:
Make the whole email import "transactional". Either by importing the whole email in one database transaction, which, i guess, may not be possible if multiple Mantis API calls are involved, or delete everything that has been created by the imported email already in case of an error.

TagsNo tags attached.

Relationships

related to 0029144 closeddregad mantisbt Adding an attachment with a long filename causes "Data too long for column 'filename'" application error 

Activities

SL-Gundam

SL-Gundam

2021-10-07 04:44

manager   ~0065896

1.
The necessary changes have been made
https://github.com/mantisbt-plugins/EmailReporting/commit/cc6d9d6e4465ef89ab53227d14b6ac62e143d48c
https://github.com/mantisbt-plugins/EmailReporting/commit/7b3c347ba471a8ca6c2795a65e82babc90b6c1ba

2.
Problematic. MantisBT supports multiple backend databases through adodb. Adding "transactional" might work with some and cause problems with another. If MantisBT used it already we could hook into that but so far i have not seen them use it.

jensberke

jensberke

2021-10-07 05:57

reporter   ~0065897

Thanks a lot, that was quick :)

As for my suggestion 2: I'm not familiar with the Mantis API available for plugins, but wouldn't it be possible to resolve these endless loops for all kinds of exceptions like this? In pseudo-code:

try {
  create_ticket_if_it_doesnt_exist_yet
  add_attachments
  add_note
} catch {
  # Cleanup, at least if the email has not been removed from the mail server yet and will subsequently result in creation these data again on next execution:
  remove_ticket_if_it_was_created
  remove_all_added_attachments
  remove_all_added_notes
}

That's not transactional as in "database transaction", but would at least manually clean up as much as possible.

SL-Gundam

SL-Gundam

2021-10-07 06:40

manager   ~0065898

That's an option yes. The problem with it would be that some users do not log the EmailReporting output. And don't check it. A loop would be noticed. A cleanup after would hide the issue and might cause it to be hidden for days or even weeks.

If we run into situations where a loop is triggered i'd much rather it be as clear as possible so that users report it and we can quickly fix it and make sure EmailReporting deals with it properly.
Most problems encountered are often database related but we've added safeguards for a decent amount of them.

jensberke

jensberke

2021-10-07 07:37

reporter   ~0065899

Ah yes, good point. Thanks for your feedback.

umar.shahzad@lampromellon.com

umar.shahzad@lampromellon.com

2021-11-11 02:02

reporter   ~0066011

this plugin not sending emails to none registered users?? please help me in this regard..

SL-Gundam

SL-Gundam

2021-11-11 12:14

manager   ~0066014

Please report a new ticket or start a new thread on the forum