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

Local dev firebase key #733

Merged
merged 5 commits into from
Sep 9, 2024
Merged

Local dev firebase key #733

merged 5 commits into from
Sep 9, 2024

Conversation

amber-emmes
Copy link
Collaborator

Part of 1054.

@amber-emmes amber-emmes requested review from a team September 3, 2024 15:02
@amber-emmes amber-emmes self-assigned this Sep 3, 2024
@amber-emmes amber-emmes requested review from JoeArmani and bransteitterbr and removed request for a team September 3, 2024 15:02
@amber-emmes amber-emmes linked an issue Sep 3, 2024 that may be closed by this pull request
index.js Outdated
// Get the API key file from Box or the DevOps team
// Do not accept PRs with the localDevFirebaseConfig import uncommented
// import { firebaseConfig as localDevFirebaseConfig} from "./src/local-dev/config.js";
const localDevFirebaseConfig = stageFirebaseConfig;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure I understand...does this point dev at the stage config until the developer comments it out and activates the line above?

What about just omitting this line const localDevFirebaseConfig = stageFirebaseConfig; and throwing a descriptive error in the else if block to avoid the config crossover?

else if (isLocalDev) {
    if (!localDevFirebaseConfig) {
        throw new Error("localDevFirebaseConfig is missing. Update your config per team specs.");
    }
    !firebase.apps.length ? firebase.initializeApp(localDevFirebaseConfig()) : firebase.app();
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was my experience that trying to require a nonexistent file resulted in an error where the page refused to load entirely, so it wouldn't allow it to get that far in the code.

Copy link
Collaborator

@JoeArmani JoeArmani Sep 4, 2024

Choose a reason for hiding this comment

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

I see. That leads to a bit of a cryptic error either way. Here's the error when we set it to stage and try to log in.
Screenshot 2024-09-04 at 10 45 30 AM

My concern is that this error would pile on top of other hard-to-diagnose errors we've seen when auth goes down or other parts of the system get interrupted. I know it's a nitpick for the everyday case, but I think it helps diagnose the problem when we have more challenging access issues. I know there have been times when the firebase emulator integration for full stack work has taken hours to debug.

A type check on localDevFirebaseConfig does allow us to show a specific error message while omitting line 9 (the reference pointing from dev -> stage). My opinion is feel like that would be simpler and helpful for debugging when more complex access issues arise.

} else if (isLocalDev) {
        if (typeof localDevFirebaseConfig === 'undefined') {
            console.error('Local development requires a localDevFirebaseConfig function to be defined in src/local-dev/config.js.');
            return;
        }
        !firebase.apps.length ? firebase.initializeApp(localDevFirebaseConfig()) : firebase.app();
} else {
Screenshot 2024-09-04 at 11 07 00 AM

I'll approve and leave it up to you...that's my thought for all three integrations. Thanks

Copy link
Collaborator

@JoeArmani JoeArmani 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, left comment

index.js Outdated
// Get the API key file from Box or the DevOps team
// Do not accept PRs with the localDevFirebaseConfig import uncommented
// import { firebaseConfig as localDevFirebaseConfig} from "./src/local-dev/config.js";
const localDevFirebaseConfig = stageFirebaseConfig;
Copy link
Collaborator

@JoeArmani JoeArmani Sep 4, 2024

Choose a reason for hiding this comment

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

I see. That leads to a bit of a cryptic error either way. Here's the error when we set it to stage and try to log in.
Screenshot 2024-09-04 at 10 45 30 AM

My concern is that this error would pile on top of other hard-to-diagnose errors we've seen when auth goes down or other parts of the system get interrupted. I know it's a nitpick for the everyday case, but I think it helps diagnose the problem when we have more challenging access issues. I know there have been times when the firebase emulator integration for full stack work has taken hours to debug.

A type check on localDevFirebaseConfig does allow us to show a specific error message while omitting line 9 (the reference pointing from dev -> stage). My opinion is feel like that would be simpler and helpful for debugging when more complex access issues arise.

} else if (isLocalDev) {
        if (typeof localDevFirebaseConfig === 'undefined') {
            console.error('Local development requires a localDevFirebaseConfig function to be defined in src/local-dev/config.js.');
            return;
        }
        !firebase.apps.length ? firebase.initializeApp(localDevFirebaseConfig()) : firebase.app();
} else {
Screenshot 2024-09-04 at 11 07 00 AM

I'll approve and leave it up to you...that's my thought for all three integrations. Thanks

@we-ai
Copy link
Collaborator

we-ai commented Sep 4, 2024

I see a bit more steps needed for local tests, but I don't see how this prevents abuse.
Any design docs I can read? @amber-emmes

@amber-emmes amber-emmes merged commit 7bd700d into dev Sep 9, 2024
@amber-emmes amber-emmes deleted the local-dev-firebase-key branch September 9, 2024 20:08
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.

Hide External API Keys
5 participants