mozilla-services / autopush

Python Web Push Server used by Mozilla
https://autopush.readthedocs.io/
Mozilla Public License 2.0
215 stars 34 forks source link

bug: report details of an FCM "INVALID_ARGUMENT" error #1430

Closed jrconlin closed 3 years ago

jrconlin commented 3 years ago

Issue #1373

Description

This is a really quick patch to try and capture the relevant details returned from FCM when it returns an INVALID_ARGUMENT error. I had thought it was related to the TTL, but we already trim it down to an appropriate max value.

Testing

Honestly, if I could figure out how to trigger this in dev, I'd be thrilled. As it is, to test this you'll need a valid FCM routing number, which means compiling an emulated FCM client app (the sample one works fine) which means updating Android Studio to 5, and fetching the latest updates, before altering the code paths and java code to match the FCM project you declared so that the downloaded google-services.json file tied to the sample app you declared in FCM match then use a combination of registration and send scripts to try to trigger an INVALID_ARGUMENT error that gets dumped out to sentry.

All for a patch to see what's going on, and not the real fix.

Issue(s)

Issue #1373

AzureMarker commented 3 years ago

I have the necessary testing setup ready, I'll try to reproduce the issue with this PR.

AzureMarker commented 3 years ago

I think the error is due to incorrectly accounting for FCM's (total) message size limit, a la https://github.com/mozilla-services/autopush-rs/issues/203. It looks like all of the message_size values in Sentry are around 4094 bytes, 2 bytes under the 4096 limit.

I was able to trigger the error by passing through a message which just passed under our size validation but when wrapped in the FCM payload was over 4096 bytes.

Edit: also the error object did not have any details: Server error: INVALID_ARGUMENT: Request contains an invalid argument. No Details

Edit 2: The full FCM response:

{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "status": "INVALID_ARGUMENT"
  }
}
jrconlin commented 3 years ago

Huh, that explains why we're not seeing additional details. Interesting. I'll try a few test runs as well and see if I can duplicate. Thanks!