If the user mistypes their password or cancels the agent operation then aerc will send an empty email before bouncing back to the review screen for another attempt. It shouldn't do that.
I'm unable to reproduce on master, both by using no password and using the wrong password 3 times. Each time I get the error
gpg: failure to encrypt: FAILURE sign-encrypt 67109041. check public key(s)
Can you confirm on master branch that this still exists for you?
I can reproduce this on master when sending encrypted emails. The email that eventually arrives gives the following error when read:
gpgmail: failed to read PGP message: gpg: decrypt_message failed: Unknown system error
Sending signed emails fail gracefully.
Sending signed emails fail gracefully.
Sorry, signed emails actually still send an empty email when they fail (it took some time to arrive). To clarify:
Signed + encrypted: sends without error, with an empty multipart email with a pgp-encrypted part that gpg cannot decrypt.
Signed: errors out and returns to the review screen, but sends an empty email
If it helps to narrow down reproduction steps, I am using pinentry-bemenu and simply pressing escape to dismiss it when prompted for a password. This is sufficient to reproduce the problem.
I wonder if it could be related to aerc not detecting an error reported by gpg after a recent change in how we read the status fd.
Could you try after reverting this commit? 5ccd2d0d518c