fix: skip extensions API check when no extensions are defined#9989
fix: skip extensions API check when no extensions are defined#9989Thepriandana wants to merge 1 commit intofirebase:mainfrom
Conversation
When deploying functions without any Firebase Extensions defined, the CLI was unnecessarily checking the firebaseextensions.googleapis.com API and requiring firebaseextensions.instances.list permission. This caused deployment failures for projects that: - Don't use Firebase Extensions at all - Have the API disabled - Don't have the required IAM permissions The fix adds an early return in prepareDynamicExtensions() when no extensions are defined in the function builds, avoiding the unnecessary API calls and permission checks. Fixes deployment errors like: Error: Request to firebaseextensions.googleapis.com returned 403
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical deployment issue for Firebase projects that do not use Firebase Extensions. By introducing an early exit condition, the system now intelligently bypasses irrelevant API calls and permission validations, ensuring smoother deployments and preventing unnecessary 403 errors. This change significantly improves the developer experience for a subset of Firebase users by streamlining the deployment process. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request aims to prevent unnecessary Firebase Extensions API calls when deploying functions in a project that doesn't use extensions. The main change correctly adds an early return if no extensions are defined in the function builds.
My review identifies two points:
- A potential side effect of the main change is that it alters the behavior for deleting dynamic extensions. I've left a comment to confirm if this is intended.
- A second change appears to introduce a critical bug that would prevent new dynamic extensions from being created. I've provided a suggestion to fix this.
Overall, the main fix is good, but the second change needs to be addressed.
| if (haveExtensions.length === 0) { | ||
| // Nothing to delete | ||
| return; | ||
| } |
There was a problem hiding this comment.
This new condition appears to introduce a bug. If a user is adding dynamic extensions to a project for the first time, haveExtensions will be empty, and this early return will prevent the new extensions from being created.
Given the check for Object.keys(extensions).length === 0 at the beginning of the function, this block is no longer necessary and can be removed entirely.
| if (Object.keys(extensions).length === 0) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
This change correctly avoids API calls when no extensions are defined in code, which fixes the issue for users not using extensions. However, this introduces a change in behavior. Previously, removing a dynamic extension from functions code and re-deploying would trigger its deletion. With this early return, deletion of dynamic extensions during a function deploy will no longer occur. Users will have to use firebase ext:uninstall instead. Is this change in workflow intended?
Problem
When deploying functions without any Firebase Extensions defined, the CLI was unnecessarily checking the
firebaseextensions.googleapis.comAPI and requiringfirebaseextensions.instances.listpermission.This caused deployment failures for projects that:
Error message:
Solution
Add an early return in
prepareDynamicExtensions()when no extensions are defined in the function builds. This avoids unnecessary API calls and permission checks for projects that don't use Firebase Extensions.Changes
Modified
src/deploy/extensions/prepare.ts:ensureExtensionsApiEnabled()andrequirePermissions()Object.keys(extensions).length === 0Testing
Verified the fix by deploying functions to a project without Firebase Extensions. Previously failed with 403 error, now deploys successfully.