mozilla / fxa-email-service

DEPRECATED - Migrated to https://github.com/mozilla/fxa
Mozilla Public License 2.0
6 stars 6 forks source link

fix(errors): convert ses invalid domain error into a 400 #260

Closed philbooth closed 5 years ago

philbooth commented 5 years ago

Fixes #248.

We've seen this in Sentry a few times, SES returns an invalid domain for some email addresses that make it through our imperfect validation regex and we transform that into a 500, which generates noise. This change parses the error payload (it's coughXMLcough), then checks the error code.

It's possible there will be other, specific error cases that we want to handle like this in the future, so I opted to bite the bullet and import a (lightweight) XML parser. We could probably have got away with a simple substring match, but this way should be more robust. I could have gone the other way of course and imported something that supports XPath, but that definitely feels like overkill for now (it may not be if future errors have significantly different payloads though).

@mozilla/fxa-devs r?