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

  1. Configure the mail system (for example Mail System module) with a sender or formatter plugin ID that does not exist.
  2. Enable "Send Email Notification on Passkey Addition".
  3. Go to /user/UID/passkeys and 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

Command icon 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

aaronbauman created an issue. See original summary.

aaronbauman’s picture

Status: Active » Needs review
mingsong’s picture

Status: Needs review » Needs work

Thanks 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.

aaronbauman’s picture

Status: Needs work » Needs review

tests fixed.
the only remaining warnings are present in upstream (next minor) and the test-only job.

mingsong’s picture

Status: Needs review » Fixed

Thank you.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.