Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: add app_id to error message #303

Merged
merged 15 commits into from
May 4, 2022
Merged

bug: add app_id to error message #303

merged 15 commits into from
May 4, 2022

Conversation

jrconlin
Copy link
Member

This patch does two things in order to determine the spike in InvalidAppId messages:

  1. Add the sent app_id to the InvalidAppId error message
  2. strip quotes from the app_id (in case this is a json string
    transposition error.)

Closes #302

This patch does two things in order to determine the spike in `InvalidAppId` messages:
1) Add the sent app_id to the InvalidAppId error message
2) strip quotes from the app_id (in case this is a json string
transposition error.)

Closes #302
@jrconlin jrconlin requested review from pjenvey and a team April 20, 2022 20:01
autoendpoint/src/routers/fcm/router.rs Outdated Show resolved Hide resolved
autoendpoint/src/routers/fcm/router.rs Outdated Show resolved Hide resolved
autoendpoint/src/routers/apns/router.rs Outdated Show resolved Hide resolved
Add minimal handling of GCM data sends. This needs to be tested on stage
(if possible. It's no longer possible to create GCM tokens to validate).

Note that this overloads "FCM" settings. See
router::fcm::settings::FcmSettings for details.

Closes: CONSVC-1765
@jrconlin jrconlin requested a review from pjenvey April 27, 2022 23:42
autoendpoint/src/routers/common.rs Show resolved Hide resolved
Some(v) => v.to_owned(),
None => {
if creds.is_none() {
return Err(FcmError::NoRegistrationToken.into());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return Err(FcmError::NoRegistrationToken.into());
return Err(FcmError::NoAppId.into());

And the same for line # 114

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argh. thanks!

autoendpoint/src/routers/fcm/client.rs Outdated Show resolved Hide resolved
autoendpoint/src/routers/fcm/settings.rs Outdated Show resolved Hide resolved
autoendpoint/src/routers/fcm/settings.rs Outdated Show resolved Hide resolved
@@ -11,6 +11,24 @@ pub struct FcmSettings {
pub min_ttl: usize,
/// A JSON dict of `FcmCredential`s. This must be a `String` because
/// environment variables cannot encode a `HashMap<String, FcmCredential>`
/// This contains both GCM and FCM credentials.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should really mention how they're distinguished here as well (existence of "{" vs base64)) with the examples below reflecting that, but I'm fine deferring this to a separate issue though.

Copy link
Member Author

@jrconlin jrconlin May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I did that at line 27, where I have credentials for both, or do you mean something else?

Ah! I see what you meant. Editing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and I found out that endpoint isn't optionally treating the credential value as a path identifier, like what the python version was doing.

if creds.is_none() {
return Err(FcmError::NoRegistrationToken.into());
}
match creds
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is pulling from creds.get("auth") even necessary? The Python gcm.py router seems to always use router_data.get("token").

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GCM stores the server credential auth token as auth. This is different from the registration id value stored in token

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it's stored as auth in router_data, but autopush python never actually reads from it. Instead the router reads auth from its own copy supplied from settings at startup (as we do in rust, reading FCMClient's credential.credential).

Whereas here we seem to be reading it as a fallback for router_data.get("token") which is registration_id, not auth (plus I don't think router_data.get("token") should ever be returning None)

Also this value's called auth in send_gcm, maybe call it token or registration_id instead?.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I think a BIG part of this is that the variables have terrible names. I'm going to try and fix that.

(The following is also for my benefit...)
What gets stored into the routing information is the project_id and the users routing_token. The project_id identifies which project to use, and is later matched with the project_id in the settings to get the corresponding server_access_token (which may be a value, a JSON block, or a file descriptor). FCM uses an authenticator function, and GCM needs to have access to the server_credentials, so both of those are stored into the FcmClient when it's initialized.

* Realized that autoendpoint was not reading credentials from files.
  This is different behavior from the python version and SRE would
  appreciate the option.
@jrconlin jrconlin requested a review from pjenvey May 3, 2022 17:25
autoendpoint/src/routers/fcm/settings.rs Outdated Show resolved Hide resolved
if creds.is_none() {
return Err(FcmError::NoRegistrationToken.into());
}
match creds
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it's stored as auth in router_data, but autopush python never actually reads from it. Instead the router reads auth from its own copy supplied from settings at startup (as we do in rust, reading FCMClient's credential.credential).

Whereas here we seem to be reading it as a fallback for router_data.get("token") which is registration_id, not auth (plus I don't think router_data.get("token") should ever be returning None)

Also this value's called auth in send_gcm, maybe call it token or registration_id instead?.

* clean up generic GCM/FCM auth terms to be clearer about what's going
on.
@jrconlin jrconlin requested a review from pjenvey May 4, 2022 21:22
Copy link
Member

@pjenvey pjenvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest of it looks good

autoendpoint/src/routers/fcm/client.rs Outdated Show resolved Hide resolved
pjenvey
pjenvey previously approved these changes May 4, 2022
@jrconlin
Copy link
Member Author

jrconlin commented May 4, 2022

Fuuuuuuuuuuuu...

@jrconlin jrconlin merged commit d2cd2ee into master May 4, 2022
@jrconlin jrconlin deleted the bug/302-appid branch May 4, 2022 23:14
@jrconlin jrconlin mentioned this pull request May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display erroneous app_id in error message
2 participants