HomePhabricator
Diffusion Comm 91f7b442cbb2

[Tunnelbroker] invalidate bad FCM tokens

Description

[Tunnelbroker] invalidate bad FCM tokens

Summary:
ENG-8498.
ENG-8824.

Keyserver code is here and here.

This is implemented according to the Detect invalid token responses from the FCM backend section in the Firebase docs.

Unfortunately, for INVALID_ARGUMENT there are no detailed docs of how the error might look like, the only information is a description of each ErrorCode. This is a common issue with Firebase, see e.g. here.

We had two options:

  1. Invalidate token for all INVALID_ARGUMENT errors - this error could be caused by multiple things e.g., a badly created HTTP request can invalidate the token.
  2. Check if the error has a message about an invalid registration token (this is a bit experimental).

The returned error looks like this:

{
  "error": {
    "code": 400,
    "message": "The registration token is not a valid FCM registration token",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
        "errorCode": "INVALID_ARGUMENT"
      }
    ]
  }
}

Based on what node SDK is doing on a keyserver this approach is basically the same, so I implemented option 2 but I am open for changing this.

Depends on D12946

Test Plan: Manually malform device token for Android in DDB, try sending notif to this device and verify that flag was flipped and the message was sent to the device (both online and offline device).

Reviewers: bartek, marcin, tomek

Reviewed By: bartek

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D12951

Details

Provenance
kamilAuthored on Jul 31 2024, 2:48 AM
Reviewer
bartek
Differential Revision
D12951: [Tunnelbroker] invalidate bad FCM tokens
Parents
rCOMM2960f788547e: [Tunnelbroker] invalidate bad Web Push tokens
Branches
Unknown
Tags
Unknown