Skip to content

Revert "Print cloudfunctions.net URL instead of run.app URL for 2nd Gen functions. (#7887)"#9922

Open
mashijp wants to merge 2 commits intofirebase:mainfrom
mashijp:fix-auth-blocking-url-7887
Open

Revert "Print cloudfunctions.net URL instead of run.app URL for 2nd Gen functions. (#7887)"#9922
mashijp wants to merge 2 commits intofirebase:mainfrom
mashijp:fix-auth-blocking-url-7887

Conversation

@mashijp
Copy link
Copy Markdown

@mashijp mashijp commented Feb 13, 2026

Description

This PR reverts commit 2690983 (PR #7887) which breaks Auth Blocking Functions in Cloud Functions v2.

PR #7887 changed createV2Function to use resultFunction.url (.cloudfunctions.net) instead of resultFunction.serviceConfig?.uri (.run.app) for endpoint.uri. This causes Auth Blocking Functions to fail with the following error:

  Firebase Auth Blocking token has incorrect "aud" (audience) claim.
  Expected "run.app" but got "https://asia-northeast1-.cloudfunctions.net/beforeSignIn".

Root Cause

While the original PR intended to display .cloudfunctions.net URLs, the implementation only modified createV2Function, leaving updateV2Function unchanged. This creates inconsistent behavior (.cloudfunctions.net on create, .run.app on update) and, more importantly, breaks Auth Blocking Functions due to a mismatch with firebase-functions' token validation logic, which expects audience = "run.app" for v2 functions.

I propose reverting this change to restore functionality and consistency.

Scenarios Tested

Before (with bug)

  • 1st deploy (create) → registers .cloudfunctions.net with Identity Platform → Auth fails
  • 2nd deploy (update) URL → registers .run.app with Identity Platform → Auth works

After

  • 1st deploy (create) URL → registers .run.app with Identity Platform → Auth works

Sample Commands

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @mashijp, 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 regression introduced by a previous change, which caused Auth Blocking Functions to fail for 2nd Generation Cloud Functions. By reverting the problematic logic, the system now correctly uses .run.app URLs for these functions, ensuring proper token validation and restoring consistent behavior across function creation and updates. The fix resolves the aud claim mismatch that was preventing authentication from working as expected.

Highlights

  • Reverted URL Logic: The pull request reverts a previous change (PR Print cloudfunctions.net URL instead of run.app URL for 2nd Gen function #7887) that incorrectly set the endpoint.uri for 2nd Generation Cloud Functions to use .cloudfunctions.net URLs instead of .run.app URLs.
  • Auth Blocking Functions Fix: This revert specifically fixes a critical issue where Auth Blocking Functions were failing due to an aud (audience) claim mismatch, as firebase-functions expects "run.app" for v2 functions.
  • Restored Consistency: The change restores consistency by ensuring that both createV2Function and updateV2Function paths correctly use .run.app URIs, resolving an inconsistency introduced by the previous PR.
  • Type Definition Update: The url property has been removed from the OutputCloudFunction type definition, aligning the type with the corrected URL handling.

🧠 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/functions/backend.spec.ts
    • Updated mock HAVE_CLOUD_FUNCTION_V2 to use RUN_URI for serviceConfig.uri.
    • Removed the url property from the mock HAVE_CLOUD_FUNCTION_V2 object.
  • src/deploy/functions/release/fabricator.ts
    • Reverted the assignment of endpoint.uri to use resultFunction.serviceConfig?.uri instead of resultFunction.url.
  • src/gcp/cloudfunctionsv2.spec.ts
    • Removed the GCF_URL constant and its usage in test data.
    • Updated mock HAVE_CLOUD_FUNCTION_V2 to remove the url property.
    • Modified various test cases to consistently use RUN_URI for endpoint.uri in expected outputs.
  • src/gcp/cloudfunctionsv2.ts
    • Removed the url: string; property from the OutputCloudFunction type definition.
    • Removed the proto.renameIfPresent(endpoint, gcfFunction, "uri", "url"); line, which was mapping url to uri.
Activity
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
Copy Markdown
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 reverts a previous change that introduced a critical bug in Auth Blocking Functions for Cloud Functions v2. The change correctly restores the logic to use the .run.app URL from serviceConfig.uri instead of the .cloudfunctions.net URL, which was causing audience validation failures. The related changes in type definitions and test files are consistent and accurately reflect this revert. The fix is sound and necessary to restore correct functionality and consistency between function creation and update operations.

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.

2 participants