Problem
When a user adds a passkey, PasskeyController saves the credential and then sends the "passkey added" notification with $this->mailManager->mail(). That call is inside the same try block as the registration. If the mail system throws, for example because a configured mail plugin does not exist, the catch block runs and returns an error. The browser shows "Error registering passkey: Passkey registration failed", although the passkey was created.
Error seen, with a mail system pointing at a plugin that is not available on the site:
The "maillog" plugin does not exist. Valid plugin IDs for Drupal\mailsystem\MailsystemManager are: ...
Steps to reproduce
- Configure the mail system (for example Mail System module) with a sender or formatter plugin ID that does not exist.
- Enable "Send Email Notification on Passkey Addition".
- Go to
/user/UID/passkeysand click "Add new passkey".
The registration reports a failure, but the passkey is listed afterwards.
Proposed resolution
Wrap the notification mail in its own try/catch (\Throwable), log the failure to the wa channel, and return the normal success response. The credential is already stored at that point, so a mail problem should not be reported as a failed registration or count against the flood limit.
Remaining tasks
- Review the patch.
- Add a test where the mail manager throws.
AI disclosure
The fix and this text were drafted with Claude (Anthropic) and reviewed by the submitter.
Issue fork wa-3641065
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
aaronbaumanComment #4
mingsongThanks for the merge request.
I noticed that there are some CI warnings with the merge request. If we could have them fixed, that would be great.
And one minor issue with the new test is D10 backwards compatibility. I made a comment on the merge request where I think could be a problem with D10.
Comment #5
aaronbaumantests fixed.
the only remaining warnings are present in upstream (next minor) and the test-only job.
Comment #7
mingsongThank you.