Skip to content

Add precondition format checks against api-key and app-id #3562

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

ChaoqunCHEN
Copy link
Contributor

@ChaoqunCHEN ChaoqunCHEN commented Aug 4, 2020

@ChaoqunCHEN ChaoqunCHEN requested review from Feiyang1 and zwu52 August 4, 2020 23:28
@ChaoqunCHEN ChaoqunCHEN requested a review from andirayo as a code owner August 4, 2020 23:28
@changeset-bot
Copy link

changeset-bot bot commented Aug 4, 2020

🦋 Changeset is good to go

Latest commit: 64edab6

We got this.

This PR includes changesets to release 13 packages
Name Type
@firebase/installations Patch
@firebase/analytics Patch
firebase Patch
@firebase/messaging Patch
@firebase/performance Patch
@firebase/remote-config Patch
@firebase/testing Patch
firebase-browserify-test Patch
firebase-package-typings-test Patch
firebase-messaging-selenium-test Patch
firebase-typescript-test Patch
firebase-webpack-test Patch
@firebase/functions Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Aug 4, 2020

Binary Size Report

Affected SDKs

  • @firebase/firestore

    Type Base (2245ad7) Head (d43993d) Diff
    browser 249 kB 249 kB -135 B (-0.1%)
    esm2017 195 kB 195 kB +15 B (+0.0%)
    main 474 kB 474 kB +42 B (+0.0%)
    module 246 kB 246 kB -113 B (-0.0%)
    react-native 195 kB 195 kB +15 B (+0.0%)
  • @firebase/firestore/exp

    Type Base (2245ad7) Head (d43993d) Diff
    browser 189 kB 189 kB +15 B (+0.0%)
    main 467 kB 467 kB +38 B (+0.0%)
    module 189 kB 189 kB +15 B (+0.0%)
    react-native 189 kB 189 kB +15 B (+0.0%)
  • @firebase/firestore/lite

    Type Base (2245ad7) Head (d43993d) Diff
    browser 64.5 kB 64.5 kB -68 B (-0.1%)
    main 141 kB 141 kB -374 B (-0.3%)
    module 64.5 kB 64.5 kB -68 B (-0.1%)
    react-native 64.6 kB 64.6 kB -68 B (-0.1%)
  • @firebase/firestore/memory

    Type Base (2245ad7) Head (d43993d) Diff
    browser 187 kB 187 kB -74 B (-0.0%)
    esm2017 146 kB 146 kB +55 B (+0.0%)
    main 348 kB 348 kB -48 B (-0.0%)
    module 185 kB 185 kB -52 B (-0.0%)
    react-native 146 kB 146 kB +55 B (+0.0%)
  • @firebase/installations

    Type Base (2245ad7) Head (d43993d) Diff
    esm2017 16.5 kB 17.5 kB +963 B (+5.8%)
    main 22.0 kB 23.0 kB +963 B (+4.4%)
    module 21.5 kB 22.5 kB +963 B (+4.5%)
  • @firebase/rules-unit-testing

    Type Base (2245ad7) Head (d43993d) Diff
    main ? 7.24 kB ? (?)
  • firebase

    Type Base (2245ad7) Head (d43993d) Diff
    firebase-analytics.js 28.3 kB 29.0 kB +697 B (+2.5%)
    firebase-firestore.js 288 kB 287 kB -110 B (-0.0%)
    firebase-firestore.memory.js 227 kB 227 kB -50 B (-0.0%)
    firebase-installations.js 19.2 kB 19.9 kB +697 B (+3.6%)
    firebase-messaging.js 40.9 kB 41.6 kB +697 B (+1.7%)
    firebase-performance-standalone.es2017.js 72.1 kB 73.5 kB +1.35 kB (+1.9%)
    firebase-performance-standalone.js 47.4 kB 48.1 kB +701 B (+1.5%)
    firebase-performance.js 37.8 kB 38.5 kB +697 B (+1.8%)
    firebase-remote-config.js 37.0 kB 37.7 kB +697 B (+1.9%)
    firebase.js 823 kB 823 kB +589 B (+0.1%)

Test Logs

Copy link
Member

@zwu52 zwu52 left a comment

Choose a reason for hiding this comment

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

Please add a changeset (which is used for generating release notes) to this PR. The instruction for how to do so is included in the Workflow check failures.

@ChaoqunCHEN ChaoqunCHEN requested a review from zwu52 August 12, 2020 21:14
Copy link
Member

@zwu52 zwu52 left a comment

Choose a reason for hiding this comment

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

LGTM . Please add an changeset to this.

Copy link
Member

@Feiyang1 Feiyang1 left a comment

Choose a reason for hiding this comment

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

Can you merge with master to refresh the size analysis? Currently it shows a 5% size increase which is too big and doesn't sound accurate.

@@ -30,6 +32,14 @@ export const enum ErrorCode {
const ERROR_DESCRIPTION_MAP: { readonly [key in ErrorCode]: string } = {
[ErrorCode.MISSING_APP_CONFIG_VALUES]:
'Missing App configuration value: "{$valueName}"',
[ErrorCode.INVALID_APP_ID_FORMAT]:
'Please set your Application ID. A valid Firebase App ID is required to communicate ' +
Copy link
Member

Choose a reason for hiding this comment

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

The message sounds like the app id is missing, but the error is actually a malformed appId. I would also just use appId which matches the name in the config object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense. done

'with Firebase server APIs: It identifies your application with Firebase.' +
'Please refer to https://firebase.google.com/support/privacy/init-options.',
[ErrorCode.INVALID_API_KEY_FORMAT]:
'Please set a valid API key. A Firebase API key is required to communicate with ' +
Copy link
Member

Choose a reason for hiding this comment

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

Similarly I would just use apiKey to match the name in the config object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -33,7 +33,10 @@ export function newTestFirestore(
}
const app =
typeof nameOrApp === 'string'
? firebase.initializeApp({ apiKey: 'fake-api-key', projectId }, nameOrApp)
? firebase.initializeApp(
{ apiKey: 'A-test-api-key-jklmnopqrstuvwxyz1234567', projectId },
Copy link
Member

Choose a reason for hiding this comment

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

Does the test fail without the change? I think you only need the correct format in installation tests, specifically the tests that involves extractAppConfig(). We can leave other places unchanged, right?

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 saw many tests were failing so I added these changes.

Copy link
Member

Choose a reason for hiding this comment

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

That is weird. I don't think your change affects firestore. Are you sure the failure comes from firestore? It will be really inconvenient if we are forced use exact 38 characters apiKey in tests.

@ChaoqunCHEN ChaoqunCHEN requested a review from Feiyang1 August 13, 2020 18:05
Copy link
Contributor

@andirayo andirayo left a comment

Choose a reason for hiding this comment

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

Removing this from my list of review-requests.

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.

5 participants