-
Notifications
You must be signed in to change notification settings - Fork 16
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
Conversation
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
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
Some(v) => v.to_owned(), | ||
None => { | ||
if creds.is_none() { | ||
return Err(FcmError::NoRegistrationToken.into()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Err(FcmError::NoRegistrationToken.into()); | |
return Err(FcmError::NoAppId.into()); |
And the same for line # 114
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
argh. thanks!
@@ -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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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")
.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?.
There was a problem hiding this comment.
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.
if creds.is_none() { | ||
return Err(FcmError::NoRegistrationToken.into()); | ||
} | ||
match creds |
There was a problem hiding this comment.
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?.
There was a problem hiding this 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
Fuuuuuuuuuuuu... |
This patch does two things in order to determine the spike in
InvalidAppId
messages:transposition error.)
Closes #302