Skip to content

FirebaseInstallations: CreateInstallation API request error handling #4024

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

Merged
merged 17 commits into from
Oct 9, 2019

Conversation

maksymmalyhin
Copy link
Contributor

@maksymmalyhin maksymmalyhin commented Oct 8, 2019

  • avoid sending CreateInstallation API requests when Firebase configuration is invalid (see go/fis-ios-error-handling for details).

@maksymmalyhin maksymmalyhin marked this pull request as ready for review October 8, 2019 22:02
Copy link
Contributor

@charlotteliang charlotteliang left a comment

Choose a reason for hiding this comment

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

looks good, just have a few questions out of curiosity on the implementations.

NSString *APIKey = self.APIService.APIKey;
NSString *projectID = self.APIService.projectID;
return (parameters.APIKey == APIKey || [parameters.APIKey isEqual:APIKey]) &&
(parameters.projectID == projectID || [parameters.projectID isEqual:projectID]);
Copy link
Contributor

Choose a reason for hiding this comment

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

parameters.APIKey == APIKey
Is this for comparing the address to be the same as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use parameters.APIKey == APIKey to cover the case when they are both nil. [parameters.APIKey isEqual:APIKey] returns NO in this case. It is the easiest way to cover all equality cases I came up with, but I am open for suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

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

nice! I didn't know that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I didn't pay attention to it until the integration tests failures. Basically if e.g. parameters.APIKey == nil then any message to it will return nil which is casted to NO.


// Save the error and then fail with the API error.
return
[self.installationsStore saveInstallation:failedInstallation].then(^NSError *(id result) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If registration returns with error, why do we still save such installation item?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a design doc link explaining the details (sorry I should've added it before). TL;DR: we would like to store the registration parameters and the error received, so we can return the error without sending the API request. We will send the API request again only if the parameters changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

what if the error is because network is not available?

Copy link
Contributor Author

@maksymmalyhin maksymmalyhin Oct 9, 2019

Choose a reason for hiding this comment

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

In this case [self doesRegistrationErrorRequireConfigChange:error] at line # 269 will return NO so the error will not be saved and the installation status will stay "unregistered".

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it thanks!

@maksymmalyhin maksymmalyhin merged commit 27384c0 into master Oct 9, 2019
@maksymmalyhin maksymmalyhin deleted the mm/fis-errors branch October 9, 2019 17:48
maksymmalyhin added a commit that referenced this pull request Oct 18, 2019
maksymmalyhin added a commit that referenced this pull request Oct 21, 2019
…simple log message. (#4120)

* Revert "FIS: stored registration error timeout (#4032)"

This reverts commit 37747db.

* Revert "FirebaseInstallations: CreateInstallation API request error handling (#4024)"

This reverts commit 27384c0.

* Complex unrecoverable error handling reverted and replaced by a simple log message.
@firebase firebase locked and limited conversation to collaborators Nov 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants