Skip to content

fix: skip extensions API check when no extensions are defined#9989

Open
Thepriandana wants to merge 1 commit intofirebase:mainfrom
Thepriandana:fix-skip-extensions-check-when-no-extensions
Open

fix: skip extensions API check when no extensions are defined#9989
Thepriandana wants to merge 1 commit intofirebase:mainfrom
Thepriandana:fix-skip-extensions-check-when-no-extensions

Conversation

@Thepriandana
Copy link

Problem

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 Firebase Extensions API disabled
  • Don't have the required IAM permissions (even for project owners)

Error message:

Error: Request to https://firebaseextensions.googleapis.com/v1beta/projects/xxx/instances?pageSize=100&pageToken= had HTTP Error: 403, The caller does not have permission

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:

  • Added early return check before calling ensureExtensionsApiEnabled() and requirePermissions()
  • Skip all extensions-related API calls when Object.keys(extensions).length === 0

Testing

Verified the fix by deploying functions to a project without Firebase Extensions. Previously failed with 403 error, now deploys successfully.

# Before fix: deployment failed with 403 permission error
# After fix: deployment succeeds
firebase deploy --only functions

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
@google-cla
Copy link

google-cla bot commented Feb 27, 2026

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.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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

  • Resolved Deployment Failures: Fixed an issue where deploying functions without Firebase Extensions would result in a 403 permission error due to unnecessary API checks against firebaseextensions.googleapis.com.
  • Optimized API Calls: Implemented an early return in prepareDynamicExtensions() to skip all extensions-related API calls and permission checks when no Firebase Extensions are defined in the function builds.
  • Improved Permissions Handling: Eliminated the requirement for firebaseextensions.instances.list permission for projects that do not utilize Firebase Extensions, preventing deployment failures for project owners without these specific IAM permissions.

🧠 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
  • src/deploy/extensions/prepare.ts
    • Added an early return check to prepareDynamicExtensions to skip extensions API calls if no extensions are defined.
    • Modified an existing conditional check to remove the redundant Object.keys(extensions).length === 0 condition after the introduction of the new early return.
Activity
  • The author identified a problem where CLI unnecessarily checked the firebaseextensions.googleapis.com API, causing 403 errors for projects without Firebase Extensions.
  • A solution was proposed to add an early return in prepareDynamicExtensions() to avoid these checks.
  • The fix was verified by deploying functions to a project without Firebase Extensions, confirming that deployments now succeed where they previously failed with a 403 error.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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:

  1. 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.
  2. 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.

Comment on lines +192 to 195
if (haveExtensions.length === 0) {
// Nothing to delete
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

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.

Comment on lines +178 to +180
if (Object.keys(extensions).length === 0) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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?

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.

1 participant