firebase-tools: `getAppEngineLocation` always returns 'us-central1'
[REQUIRED] Environment info
firebase-tools: 7.1.0
Platform: macOS Mojave 10.14.5, Node v8.15.1
[REQUIRED] Test case
Deploy a cloud functions project (with scheduled functions) with an app engine location set to another region (e.g. europe-west1
)
[REQUIRED] Steps to reproduce
firebase deploy --force --only functions --project some_project_id
[REQUIRED] Expected behavior
The function should return the location of the app engine found within context.firebaseConfig
.
e.g. App engine location set to europe-west1
should return europe-west1
[REQUIRED] Actual behavior
The function returns the default us-central1
value.
[2019-07-12T15:24:13.299Z] Error Context: {
"body": {
"error": {
"code": 400,
"message": "Location must equal europe-west1 because the App Engine app that is associated with this project is located in europe-west1",
"status": "INVALID_ARGUMENT"
}
},
"response": {
"statusCode": 400,
"body": {
"error": {
"code": 400,
"message": "Location must equal europe-west1 because the App Engine app that is associated with this project is located in europe-west1",
"status": "INVALID_ARGUMENT"
}
},
"headers": {
"vary": "X-Origin, Referer, Origin,Accept-Encoding",
"content-type": "application/json; charset=UTF-8",
"date": "Fri, 12 Jul 2019 15:24:13 GMT",
"server": "ESF",
"cache-control": "private",
"x-xss-protection": "0",
"x-frame-options": "SAMEORIGIN",
"x-content-type-options": "nosniff",
"alt-svc": "quic=\":443\"; ma=2592000; v=\"46,43,39\"",
"accept-ranges": "none",
"transfer-encoding": "chunked"
},
"request": {
"uri": {
"protocol": "https:",
"slashes": true,
"auth": null,
"host": "cloudscheduler.googleapis.com",
"port": 443,
"hostname": "cloudscheduler.googleapis.com",
"hash": null,
"search": null,
"query": null,
"pathname": "/v1beta1/projects/some_project_id/locations/us-central1/jobs/firebase-schedule-functionName-europe-west1",
"path": "/v1beta1/projects/some_project_id/locations/us-central1/jobs/firebase-schedule-functionName-europe-west1",
"href": "https://cloudscheduler.googleapis.com/v1beta1/projects/some_project_id/locations/us-central1/jobs/firebase-schedule-functionName-europe-west1"
},
"method": "PATCH"
}
}
}
It seems as though the context.firebaseConfig
does not have a cloudResourceLocation
field (which is being used to identify the AppEngineLocation) so it is always returning undefined
. Changing that field to locationId
fixed this issue for me.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 18 (4 by maintainers)
@joehan solution from @PatNeedham isn’t working for me, I’m using firebase 7.8.2 and I’ve set region of GCP in Firebase console.
Here’s detailed log:
And with .region(‘europe-west1’):
@MaffooBristol I heard back from Firebase support after my last comment on this thread, and the response I got helped eliminate the issue:
On the https://console.firebase.google.com/u/0/project/PROJECT-ID/settings/general/ page - I set it to us-east4 and the Firebase functions deployments have been error-free since then thankfully!
Same exact issue on my end, but with
us-east4
instead ofeurope-west1
. Posted on the firebase slack and reached out to the support team, still no resolution. @mbleigh is there any command line argument to include withfirebase deploy --only functions
to give verbose output that could include some sort of deployment attempt ID, which could then be passed on to the right folks to check internal system logs?I am having this issue only with
.schedule()
This works:
This does not:
When I ran it with
--debug
, you can see some really weird URL formation where it’s combining us-central1 and europe-west1 🤔 https://cloudscheduler.googleapis.com/v1beta1/projects/my-project/locations/us-central1/jobs/firebase-schedule-schedule-europe-west1Same here; I don’t even know what change inbetween two deploy but now I get
Error: HTTP Error: 400, Location must equal europe-west1 because the App Engine app that is associated with this project is located in europe-west1
. Setting region.region('europe-west1')
on functions don’t change anything.Do you guys found a workaround ?
Hey @MaffooBristol, thanks for digging into the codebase on this one and thank you for the PR! Hopefully I can clarify some of the confusion here. That line you found is intentional, though it’s definitely weird looking.
name: `projects/${projectId}/locations/${appEngineLocation}/jobs/firebase-schedule-${functionName}-${region}
AppEngineLocation is the ‘real’ location here. This code deploys a Cloud Scheduler job in your project, and Cloud Scheduler jobs can only be deployed into the same region as your AppEngine. The original error you saw shows this (Error: HTTP Error: 400, Location must equal europe-west1 because the App Engine app that).
Region is the location where your Cloud Function is deployed. We suffix the Cloud Schedule name with this so that we can keep track of which function that schedule is calling. It doesn’t have any effect on where your stuff gets deployed in this context.
The issue you’re running into is that the API we call to figure out your appEngineLocation isn’t returning a value for it, and we default to us-central1. We are looking into why that API is misbehaving here, but for now, I’d recommend trying the solution that @PatNeedham suggested.
I went into the code and edited this line: https://github.com/firebase/firebase-tools/blob/master/src/functionsConfig.js#L53 to be
'europe-west1'
and it started working.Then I found that I could replace the following line in https://github.com/firebase/firebase-tools/blob/master/src/deploy/functions/createOrUpdateSchedulesAndTopics.ts#L58
with
…and it works as expected too.
But I’m wondering, what even is it meant to be doing? Why do some parts of the codebase use the app engine location and others use the one specified? In fact in this instance it uses two different region definitions in one line of code.
I’m brand new to this codebase so I don’t know what’s intentional or not, but hopefully this can help shed some further light on this now closed issue.
Am I missing something?
Hi everyone, thanks for reporting and apologies for this issue. We have identified the bug on our end and are working on a fix. Meanwhile, please use firebase-tools <=v7.0.2.
Thanks for everyone’s patience!