<div class="gmail_quote"><div>Hi, I&#39;m currently working with a RT 3 instance and I&#39;ve found that some Tickets could be created with missing content under specific situations.</div><div>This is my scenario:</div><div>
* RT 3.8.7 runnig on RHEL5 with perl 5.8.8</div>
<div>* Oracle 10g database</div><div>* External mail server and fetchmail to recover emails</div><div><br></div><div>This RT instance is quite special, we recive a lot of spam (we are working to fix it) and the database grows quickly. During working days our monitoring agents alert us about reaching  database space limit, but if this happen on weekend, nobody extends de DB until Monday. </div>

<div>Because of Spam we have configured fetchmail with &quot;no keep&quot; option, so if Ticket creation fails and fetchmail does not recieve an error return code the information of the email is lost.</div><div>I know that this are a lot of &quot;special situations&quot; but I think that rt-mailgate should return non zero result when RT couldn&#39;t create the Ticket correctly.</div>

<div>I haven&#39;t try to reproduce with other databases than Oracle, but I&#39;ve reproduce this behavior on two different Oracle instances</div><div>This are the steps to reproduce the issue:</div><div><br></div><div>When rt database tablesapce is full, fetchmail try to recover an email (with an attachment or an html email).</div>

<div>Ticket is created but we end up with no attach or no text if email was html.</div><div>Fetchmail recive a 0 ret code and erase email from server.</div><div><br></div><div>I&#39;ve attach the rt log when attachment insert fails.</div>

<div><br></div><div>I don&#39;t know if this is a bug or that&#39;s the way it&#39;s supposed to work, but we can&#39;t loose the email information.</div><div>If this is a bug, I think that could be generated by the scope of the variable $id in this code (Attachment_Overlay line 140)</div>

<div><br></div><div>    # If a message has no bodyhandle, that means that it has subparts (or appears to)</div><div>    # and we should act accordingly.</div><div>    unless ( defined $Attachment-&gt;bodyhandle ) {</div>
<div>
        my ($id) = $self-&gt;SUPER::Create(</div><div>            TransactionId =&gt; $args{&#39;TransactionId&#39;},</div><div>            Parent        =&gt; $args{&#39;Parent&#39;},</div><div>            ContentType   =&gt; $Attachment-&gt;mime_type,</div>

<div>            Headers       =&gt; $head,</div><div>            MessageId     =&gt; $MessageId,</div><div>            Subject       =&gt; $Subject,</div><div>        );</div><div><br></div><div>        unless ($id) {</div>

<div>            $RT::Logger-&gt;crit(&quot;Attachment insert failed - &quot;. $RT::Handle-&gt;dbh-&gt;errstr);</div><div>        }</div><div><br></div><div>        foreach my $part ( $Attachment-&gt;parts ) {</div><div>
            my $SubAttachment = new RT::Attachment( $self-&gt;CurrentUser );</div>
<div>            my ($id) = $SubAttachment-&gt;Create(</div><div>                TransactionId =&gt; $args{&#39;TransactionId&#39;},</div><div>                Parent        =&gt; $id,</div><div>                Attachment    =&gt; $part,</div>

<div>            );</div><div>            unless ($id) {</div><div>                $RT::Logger-&gt;crit(&quot;Attachment insert failed: &quot;. $RT::Handle-&gt;dbh-&gt;errstr);</div><div>            }</div><div>        }</div>

<div>        return ($id);</div><div>    }</div><div><br></div><div>    #If it&#39;s not multipart</div><div>    else {</div><div><br></div><div>        my ($ContentEncoding, $Body) = $self-&gt;_EncodeLOB(</div><div>            $Attachment-&gt;bodyhandle-&gt;as_string,</div>

<div><br></div><div><br></div><div>If the first SUPER::Create is successfull, the $id value isn&#39;t undef, but within the foreach loop, if an error ocurred adding Subattachments the crit message is printed because the inner $id is undef, but the returned value is the outer $id that is not undef, so the Ticket is created despite the error adding a subattachment. Adding a return($id) inside the foreach loop solves the problem an RT knows that Ticket can not be completly created.</div>

<div><br></div><div>This post is too long and don&#39;t want to add more info (specially with this terrible bad english), but despite the error returned to rt-mailgate when Ticket creation fails, it tells fetchmail that everything is ok and email is deleted. I&#39;ve made an ugly hack to make it work, but I think that check_for_failure() in rt-mailgate could get te correct return code, I&#39;m not a perl expert and couldn&#39;t make it work, any help?</div>

<div><br></div><div>Anyway, do you think that this is a bug or a feature?</div><div>Best regards.</div><div>Andres.</div><div><br></div>
</div><br>