Repository navigation
chore: migrate region references from us-central1 to us-east4 - #1327
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates multiple Firebase Cloud Functions samples across Node and Python to change the default region from us-central1 to us-east4 in documentation, configuration, and code. It also adds declarative API and IAM role requirements using requiresRole and requiresAPI. The review feedback highlights critical issues where requiresRole and requiresAPI are incorrectly imported from firebase-functions/v2 instead of the top-level firebase-functions package, which would cause runtime errors. Additionally, some region updates in comments are misleading, such as referencing us-east4 for Firebase Realtime Database (which is not available in that region) or contradicting the actual configured regions of the function.
|
|
||
| // [START remote_config_server_vertex_init] | ||
| const { onCall, HttpsError } = require("firebase-functions/https"); | ||
| const { requiresRole, requiresAPI } = require("firebase-functions/v2"); |
There was a problem hiding this comment.
The functions requiresRole and requiresAPI are top-level exports of the firebase-functions package, not firebase-functions/v2. Importing them from firebase-functions/v2 will result in undefined and cause runtime/deployment errors.
| const { requiresRole, requiresAPI } = require("firebase-functions/v2"); | |
| const { requiresRole, requiresAPI } = require("firebase-functions"); |
| */ | ||
|
|
||
| const {onCall} = require("firebase-functions/https"); | ||
| const {requiresRole, requiresAPI} = require("firebase-functions/v2"); |
There was a problem hiding this comment.
The functions requiresRole and requiresAPI are top-level exports of the firebase-functions package, not firebase-functions/v2. Importing them from firebase-functions/v2 will result in undefined and cause runtime/deployment errors.
| const {requiresRole, requiresAPI} = require("firebase-functions/v2"); | |
| const {requiresRole, requiresAPI} = require("firebase-functions"); |
| // [START import] | ||
| // The Cloud Functions for Firebase SDK to set up triggers and logging. | ||
| const {onConfigUpdated} = require("firebase-functions/remoteConfig"); | ||
| const {requiresRole, requiresAPI} = require("firebase-functions/v2"); |
There was a problem hiding this comment.
The functions requiresRole and requiresAPI are top-level exports of the firebase-functions package, not firebase-functions/v2. Importing them from firebase-functions/v2 will result in undefined and cause runtime/deployment errors.
| const {requiresRole, requiresAPI} = require("firebase-functions/v2"); | |
| const {requiresRole, requiresAPI} = require("firebase-functions"); |
| @@ -1,11 +1,17 @@ | |||
| // [START remote_config_server_vertex_init] | |||
| const { onRequest } = require("firebase-functions/https"); | |||
| const { requiresRole, requiresAPI } = require("firebase-functions/v2"); | |||
There was a problem hiding this comment.
The functions requiresRole and requiresAPI are top-level exports of the firebase-functions package, not firebase-functions/v2. Importing them from firebase-functions/v2 will result in undefined and cause runtime/deployment errors.
| const { requiresRole, requiresAPI } = require("firebase-functions/v2"); | |
| const { requiresRole, requiresAPI } = require("firebase-functions"); |
| // Dependencies for task queue functions. | ||
| const {onTaskDispatched} = require("firebase-functions/tasks"); | ||
| const {onRequest, HttpsError} = require("firebase-functions/https"); | ||
| const {requiresRole, requiresAPI} = require("firebase-functions/v2"); |
There was a problem hiding this comment.
The functions requiresRole and requiresAPI are top-level exports of the firebase-functions package, not firebase-functions/v2. Importing them from firebase-functions/v2 will result in undefined and cause runtime/deployment errors.
| const {requiresRole, requiresAPI} = require("firebase-functions/v2"); | |
| const {requiresRole, requiresAPI} = require("firebase-functions"); |
| * https://us-east4-<project-id>.cloudfunctions.net/date?format=MMMM%20Do%20YYYY%2C%20h%3Amm%3Ass%20a | ||
| * Example request using request body with cURL: | ||
| * curl -H 'Content-Type: application/json' / | ||
| * -d '{"format": "MMMM Do YYYY, h:mm:ss a"}' / | ||
| * https://us-central1-<project-id>.cloudfunctions.net/date | ||
| * https://us-east4-<project-id>.cloudfunctions.net/date |
There was a problem hiding this comment.
The example URLs in the comments refer to us-east4, but the function is explicitly configured to deploy to us-west1 and us-east1 on line 48. The comments should be updated to use one of the configured regions (e.g., us-east1) to avoid confusing users.
| * https://us-east4-<project-id>.cloudfunctions.net/date?format=MMMM%20Do%20YYYY%2C%20h%3Amm%3Ass%20a | |
| * Example request using request body with cURL: | |
| * curl -H 'Content-Type: application/json' / | |
| * -d '{"format": "MMMM Do YYYY, h:mm:ss a"}' / | |
| * https://us-central1-<project-id>.cloudfunctions.net/date | |
| * https://us-east4-<project-id>.cloudfunctions.net/date | |
| * https://us-east1-<project-id>.cloudfunctions.net/date?format=MMMM%20Do%20YYYY%2C%20h%3Amm%3Ass%20a | |
| * Example request using request body with cURL: | |
| * curl -H 'Content-Type: application/json' / | |
| * -d '{"format": "MMMM Do YYYY, h:mm:ss a"}' / | |
| * https://us-east1-<project-id>.cloudfunctions.net/date |
| // Listens for new messages added to /messages/:pushId/original and creates an | ||
| // uppercase version of the message to /messages/:pushId/uppercase | ||
| // for all databases in 'us-central1' | ||
| // for all databases in 'us-east4' |
There was a problem hiding this comment.
Firebase Realtime Database is not available in the us-east4 region. The only available regions for RTDB are us-central1, europe-west1, and asia-southeast1. Changing this comment to us-east4 is misleading as there are no RTDB instances in that region.
| // for all databases in 'us-east4' | |
| // for all databases in 'us-central1' |
82e8b82 to
9fa269a
Compare
9fa269a to
5f49471
Compare
Reverts the region strings from #1327 (90765b3). That change assumed the default region for Cloud Functions had moved to us-east4. It hasn't: the Firebase CLI still falls back to us-central1 for HTTP, callable, scheduled, and task queue functions, and none of these samples set a region. us-east4 is the new default for App Hosting and Data Connect, not for Functions. Kept from #1327: - the `.value` on SupportedRegion in the Python task queue samples - the requiresRole/requiresAPI import from the firebase-functions root - the us-east1 example URLs in Node/quickstarts/https-time-server, which deploys to us-west1 and us-east1 Supersedes #1346.
Replaces all us-central1 and US_CENTRAL1 references across Node, Node-1st-gen, and Python samples with us-east4 and US_EAST4, and uses SupportedRegion.US_EAST4.value when interpolating into URLs and queue paths (superseding #1120).