deltachat-core-rust icon indicating copy to clipboard operation
deltachat-core-rust copied to clipboard

Message is saved even if no recipient is available

Open nicodh opened this issue 6 months ago • 1 comments

Followup to #6847

If a message can't be send since the recipient key is missing, the message should not be saved in database.

Current behaviour: the message is saved in state "pending"

To reproduce (in Desktop):

In a chatmail account create a group with a non verified contact

Send a message to that user

An error is shown (when https://github.com/deltachat/deltachat-desktop/issues/5092 is merged )

Leave the chat and open it again

The message is shown in state "Pending"

nicodh avatar May 12 '25 11:05 nicodh

If i try to reproduce this with Desktop 1.59.1 (Core v1.159.5), i see the message in the "Failed" state (with red exclamation mark), even if i leave the chat and re-enter it. Message info:

Sent: 2025.06.05 08:45:49 by Me ([email protected])
State: Failed
Error: Permanent SMTP error: permanent: Encryption Needed: Invalid Unencrypted Mail
Message-ID: 32ef35ba-dffd-466a-84a1-7921d5fde409@localhost

No Hop Info


sent	Thursday, June 5, 2025 8:45 AM (1749123949000)
messageId	15

This looks as the expected behavior. Leaving/re-entering the account also changes nothing.

iequidoo avatar Jun 05 '25 11:06 iequidoo

This is still the case with the 2.x core, although the use case "should" not occur anymore. When investigating https://github.com/deltachat/deltachat-desktop/issues/5414 I tried to reproduce a scenario where the message can't be sent to a group by "manipulating" the database and remove the fingerprint for a group member. (I could not reproduce the scenario described in the bug report) send_msg throws an error "Failed to send created message: Failed to create send jobs: member_fingerprints.len() (3) < to.len() (4)" error comes from https://github.com/chatmail/core/blob/ff0d5ce179a714a8372ecf0668557e1aeae76216/src/mimefactory.rs#L387

In desktop an error is shown to the user and the draft text is kept in composer input. So far everything looks correct, but when revisiting the chat we suddenly see all the faild message(s) in pendings state and in the database I see that all the failed messages are stored in state "pending"

I assume that we need some error handling around MimeFactory::from_msg in https://github.com/chatmail/core/blob/ff0d5ce179a714a8372ecf0668557e1aeae76216/src/chat.rs#L3006 at least change the status to DC_STATE_OUT_FAILED if it has an error

As mentioned I don't know which scenario triggered the wrong status in #5414 but I think the behaviour to save failed messages in status pending is false.

nicodh avatar Sep 01 '25 08:09 nicodh