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

Throw exception when projectID is missing from FIROptions #7725

Merged
merged 5 commits into from
Mar 19, 2021

Conversation

karenyz
Copy link
Contributor

@karenyz karenyz commented Mar 16, 2021

If projectID is missing the fetch request can't succeed, so we can fail the request before sending it to the server. This is causing some downstream issues (tracked in b/167621250)

@google-oss-bot
Copy link

google-oss-bot commented Mar 16, 2021

Coverage Report

Affected SDKs

  • FirebaseRemoteConfig-iOS-FirebaseRemoteConfig.framework

    SDK overall coverage changed from 81.14% (1f2f5f6) to 81.20% (10c49f7) by +0.07%.

    Filename Base (1f2f5f6) Head (10c49f7) Diff
    FIRRemoteConfigComponent.m 96.05% 96.15% +0.10%
    RCNConfigFetch.m 81.70% 81.96% +0.26%

Test Logs

@paulb777
Copy link
Member

FIS, an RC dependency, should already be checking the FIROptions, so it's not clear what this is changing. Also, this might be considered a breaking change, so assigning to @ryanwilson to approve from an API perspective.

Copy link
Contributor

@maksymmalyhin maksymmalyhin left a comment

Choose a reason for hiding this comment

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

LGTM.

Note, the change could be considered as a breaking, but most like is not. RC has a dependency on FIS which already throws on the missing project ID, so the exception won't be new for existing RC clients.

Please wait for @ryanwilson for the final approval on the API change.

FirebaseRemoteConfig/Sources/RCNConfigFetch.m Outdated Show resolved Hide resolved
@ryanwilson
Copy link
Member

ryanwilson commented Mar 16, 2021

Note, the change could be considered as a breaking, but most like is not. RC has a dependency on FIS which already throws on the missing project ID, so the exception won't be new for existing RC clients.

Looking at the internal bug though, it seems like they're getting through even with the dependency on FIS so I'm concerned this is going to break someone. Do we know if that's an older version sending the data, maybe pre-FIS? @karenyz

@maksymmalyhin
Copy link
Contributor

Looking at the internal bug though, it seems like they're getting through even with the dependency on FIS so I'm concerned this is going to break someone. Do we know if that's an older version sending the data, maybe pre-FIS? @karenyz

Note, FIS started throwing the exception on the missing project ID since last major version bump.

@karenyz
Copy link
Contributor Author

karenyz commented Mar 16, 2021

I was hoping to fix-forward so we would stop sending invalid URLs moving forward, but since FIS is already throwing an exception it seems like this change doesn't make much of a difference (maybe makes it clearer for RC users?)

@ryanwilson yeah the malformed requests are from older versions, so this change wouldn't affect those requests

Copy link

@erikeldridge erikeldridge left a comment

Choose a reason for hiding this comment

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

We chatted in person, and this change may not be necessary, but if we do make it, I've added comments voting in favor of just asserting required configuration in FIRRemoteConfigComponent.m.

@@ -38,6 +38,8 @@ - (FIRRemoteConfig *)remoteConfigForNamespace:(NSString *)remoteConfigNamespace
errorPropertyName = @"googleAppID";
} else if (options.GCMSenderID.length == 0) {
errorPropertyName = @"GCMSenderID";
} else if (options.projectID.length == 0) {

Choose a reason for hiding this comment

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

Since projectID is static configuration, validating it during Component initialization is intuitive, so I think checking here is optimal, and the only change we need to make.

FirebaseRemoteConfig/Sources/RCNConfigFetch.m Outdated Show resolved Hide resolved
serverURLStr = [serverURLStr stringByAppendingString:_options.projectID];
} else {
FIRLogError(kFIRLoggerRemoteConfig, @"I-RCN000070",
@"Missing `projectID` from `FirebaseOptions`, please ensure the configured "
Copy link

Choose a reason for hiding this comment

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

I've recommended just asserting project ID as a required input in FIRRemoteConfigComponent.m. Given that, and since project ID is the only thing we're checking here, simplifying this class by removing this logging makes sense.

@@ -167,6 +167,35 @@ - (void)testThrowsWithNilGCMSenderID {
XCTAssertThrows([component remoteConfigForNamespace:@"some_namespace"]);
}

- (void)testThrowsWithEmptyProjectID {

Choose a reason for hiding this comment

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

The fact we're only asserting FIRRemoteConfigComponentTest.m throws supports the idea that validating inputs there is sufficient.

@ryanwilson
Copy link
Member

LGTM from an API standpoint since this is a no-op

Copy link

@erikeldridge erikeldridge left a comment

Choose a reason for hiding this comment

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

Shipit! 🚢

@karenyz karenyz merged commit 6e11684 into master Mar 19, 2021
@karenyz karenyz deleted the kz-rc-projectid branch March 19, 2021 16:48
@firebase firebase locked and limited conversation to collaborators Apr 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants