FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

refactor: resolve function regions during build phase to fix VPC connectors by wandamora · Pull Request #10471 · firebase/firebase-tools · GitHub

refactor: resolve function regions during build phase to fix VPC connectors - #10471

Merged
wandamora merged 5 commits into
mainfrom
ajp-speculative-tbd-fix-yolo
May 12, 2026
Merged

refactor: resolve function regions during build phase to fix VPC connectors#10471
wandamora merged 5 commits into
mainfrom
ajp-speculative-tbd-fix-yolo

Conversation

wandamora commented May 7, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

This moves the resolution logic to be before we resolve the build to a backend to set the defaults in functions, and the correct region can be known when building the VPC connector identfier.

Scenarios Tested

Create function with VPC connector
firebase deploy --only functions on 15.16.0
Update function and use local firebase-tools build
firebase deploy --only functions
Update was successful.

gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Code Review

This pull request refactors the region resolution logic for Cloud Functions, shifting the resolution process from the Backend representation to the Build representation. This allows for correct VPC connector string construction earlier in the deployment process. The new resolveDefaultRegionsForBuild function integrates existing region matching and trigger-based resolution. Review feedback identifies a violation of the style guide regarding the use of the any type and suggests including the endpoint ID in resolver calls to avoid potential issues. Additionally, a suggestion was made to use falsy checks for array length in accordance with project conventions.

Comment thread src/deploy/functions/prepare.ts Outdated
wandamora changed the title Ajp speculative tbd fix yolo refactor: resolve function regions during build phase to fix VPC connectors May 7, 2026
wandamora marked this pull request as ready for review May 7, 2026 22:48

shettyvarun268 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

Copy link
Copy Markdown
Contributor

Might want to rebase this PR to take in Joe's changes for the test cases failing.

wiz-9635d3485b Bot commented May 11, 2026
edited
Loading

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
 Vulnerabilities -
 Sensitive Data -
 Secrets -
 IaC Misconfigurations -
 SAST Findings -
 Software Management Findings -
Total -

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

wandamora force-pushed the ajp-speculative-tbd-fix-yolo branch from c9bded9 to 53f8bc3 Compare May 11, 2026 23:56
wandamora enabled auto-merge (squash) May 12, 2026 15:31
wandamora merged commit a605414 into main May 12, 2026
52 checks passed
wandamora deleted the ajp-speculative-tbd-fix-yolo branch May 12, 2026 15:44

ajperel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

My AI review prompt had a few more good suggestions we can consider for a follow up PR.

} else {
// Match triggers.
try {
const fullEndpoint = { ...endpoint, id } as any;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is done because endpoint (of type build.Endpoint) does not have an id field, but resolveRegionForEventTrigger expects a backend.Endpoint which requires an id. While this works, it bypasses TypeScript's type checks. Consider defining a minimal interface for what resolveRegionForEventTrigger actually needs (it seems to only need project and eventTrigger) or casting to a specific type that fulfills that contract rather than any.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Follow up: #10504

if (build.isBlockingTriggered(endpoint)) {
resolvedRegion = resolveRegionForBlockingTrigger(fullEndpoint);
} else if (build.isEventTriggered(endpoint)) {
resolvedRegion = await resolveRegionForEventTrigger(fullEndpoint);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If a user has many event-triggered functions, this will execute network calls (like fetching database or bucket locations) sequentially (because of the for loop it's in), which can slow down the prepare phase. Consider gathering the promises and using Promise.all to resolve them in parallel.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Daniel once advised against using Promise.all() since transient errors could bubble up in the CLI in a way that looks cryptic to the end user.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

#10414 (comment) for reference

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ok. That's a good counter argument. I think it'd be good for us to see what the cryptic error is and if we could fix it so things can be faster. But I guess let's save that for a day when we need to improve performance.

expect(want.endpoints["id"].region).to.deep.equal(["us-east1"]);
});

it("resolves region to us-east1 and correctly formats VPC connector path with us-east1", async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

AI suggests also testing this case:

Pre-formatted VPC Connector Paths:
Scenario: An endpoint with a vpc.connector that is already a full resource path (e.g., projects/my-project/locations/us-east1/connectors/my-connector).
Purpose: Verify that the resolution logic does not attempt to prefix it again or corrupt it, even after the region is resolved. This ensures the check connector.includes("/") in build.ts works correctly in this flow.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Follow up: #10505

bkendall pushed a commit that referenced this pull request Jul 9, 2026
…ectors (#10471)

* Attempt to resolve function regions earlier before used for VPC.

* lint fixes

* Check for REGION_TBD, update tests

* Add CHANGELOG entry

---------

Co-authored-by: Andy Perelson <ajp@google.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

deploys with 15.17.0 fail without explicit setGlobalOptions({ region: 'us-central1' }) with vpcConnector

4 participants


Back | FazBrowse Home | New Git URL