# Bug OP-20509 - Email replies to a locked forum topic crash the mail handler

Project: OpenProject
Status: tested
URL: https://community.openproject.org/work_packages/OP-20509

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module | Modules and project features / Forums |
| Target versions | 18.0.0 |
| Observed in versions | 17.9.0 |
| Sprint |  |
| Backlog bucket |  |
| Bug found in version (deprecated) |  |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

### Before filing a report

Found by reading the code while fixing spelling (<mention class="mention" data-id="OP-20508" data-type="work_package" data-text="#OP-20508">#OP-20508</mention>). The steps below are derived from the code and have not yet been reproduced by a person.

### Steps to reproduce

1.  Configure incoming email (IMAP or POP3) and make sure forum notifications reach user U, who has the "Post messages" permission.
2.  In a forum, post a topic, then edit it and tick **Locked**.
3.  As U, reply to the topic's notification email, keeping the `References` header and sending from U's registered address.
4.  Run the mail receive task.

### What is the buggy behavior?

Processing raises (`NameError` for `sender_email`, then `ArgumentError: unknown keyword: :mesage_type`) instead of ignoring the reply:

  - IMAP logs "resulted in error" and moves the mail to the failure folder.
  - POP3 aborts the run and retries the same mail on every poll, blocking the mails behind it.
  - `rake redmine:email:receive` crashes.

### What is the expected behavior?

The reply is ignored with the warning "ignoring reply from \[address\] to a locked topic". No message is posted. If **Report incoming email errors** is on, the sender gets the usual error report email.

### Important note

QA: with **Report incoming email errors** enabled, check that the sender receives the error report for the ignored reply. That email is new behaviour; before the fix the crash meant nothing was sent.
