We often receive alerts from android sender lambda about Firebase API returning 404 Requested entity not found errors.
From the documentation, the error is raised when the device token we want to send a notification to is invalid, is unregistered, or has expired. A device token becomes unregistered when, for example, the user uninstalls / reinstalls the app. So it happens in normal situation.
This PR checks the details field of error messages from Firebase API and identifies invalid token errors. The notification service already has a component to delete invalid tokens from the registration database.
How to test
We deployed to CODE and sent a test notification. A notification was received successfully on my Android emulator. The logs showed that some invalid token errors were returned by Firebase APIs and those tokens were then sent to a SQS for cleanup lambda to pick up.
The log message also showed that we were able to identify invalid tokens from the 404 response, where the FCM error code is Unregistered and the message is Requested entity not found.
All deployment options
- [Deploy build 4409 of `mobile-n10n:notificationworkerlambda` to CODE](https://riffraff.gutools.co.uk/deployment/deployAgain?project=mobile-n10n%3Anotificationworkerlambda&build=4409&stage=CODE&updateStrategy=MostlyHarmless&action=deploy)
- [Deploy parts of build 4409 to CODE by previewing it first](https://riffraff.gutools.co.uk/preview/yaml?project=mobile-n10n%3Anotificationworkerlambda&build=4409&stage=CODE&updateStrategy=MostlyHarmless)
- [What's on CODE right now?](https://riffraff.gutools.co.uk/deployment/history?projectName=mobile-n10n%3Anotificationworkerlambda&stage=CODE)
What does this change?
We often receive alerts from android sender lambda about Firebase API returning 404
Requested entity not found
errors.From the documentation, the error is raised when the device token we want to send a notification to is invalid, is unregistered, or has expired. A device token becomes unregistered when, for example, the user uninstalls / reinstalls the app. So it happens in normal situation.
This PR checks the
details
field of error messages from Firebase API and identifies invalid token errors. The notification service already has a component to delete invalid tokens from the registration database.How to test
We deployed to CODE and sent a test notification. A notification was received successfully on my Android emulator. The logs showed that some invalid token errors were returned by Firebase APIs and those tokens were then sent to a SQS for cleanup lambda to pick up.
The log message also showed that we were able to identify invalid tokens from the 404 response, where the FCM error code is
Unregistered
and the message isRequested entity not found
.