firebase-tools: Cannot deploy Angular SSR application using firebase deploy

[REQUIRED] Environment info

13.7.5

firebase-tools:

macOS / Ubuntu in GitHub Actions

Platform:

[REQUIRED] Test case

Deployment of Angular using Firebase Webframeworks fails due to runtimeClassName error

[REQUIRED] Steps to reproduce

  1. Create firebase project and upgrade it to blaze plan
  2. Create a new Angular Project using ng new. Select Y on the question to enable SSR
  3. Add Angularfire using ng add @angular/fire
  4. Enable ng deploy for hosting
  5. Without changes deploy hosting using ng deploy

[REQUIRED] Expected behavior

Deployment of hosting and SSR Function should work without problems.

[REQUIRED] Actual behavior

Deployment fails with result: Error: Failed to replace Run service projects/123456789/locations/us-east1/services/ssrtestdeployxxxxxx

Google Cloud logging tells the following error spec.template.spec.runtimeClassName: When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update

About this issue

  • Original URL
  • State: open
  • Created 2 months ago
  • Reactions: 18
  • Comments: 27 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Same error here… for those in need to deploy immediately, disabling pintags firebase experiments:disable pintags before deploying should make it go through.

No solution, but I found out what’s going on under the hood:

firebase-tools makes a GET request for the cloud run resource https://github.com/firebase/firebase-tools/blob/24accb1ad7773045808e78794f7c946cc60bb0bf/src/hosting/runTags.ts#L102

The result of that call contains the annotation run.googleapis.com/base-images but not the runtimeClassName attribute. Afterwards the function ensureLatestRevisionTagged https://github.com/firebase/firebase-tools/blob/24accb1ad7773045808e78794f7c946cc60bb0bf/src/hosting/runTags.ts#L144 modifies the resource and adds a tag.

Instead of patching the cloud run service using a PATCH call, it uses a PUT call to replace the whole service resource. This PUT call fails with the mentioned error message, since the original result from the GET call above did include the annotation but not the runtimeClassName attribute.

Not sure who to blame here, but I think two parties have bugs:

  1. The cloud run http api should return the attribute runtimeClassName in the service template spec. The attribute is visible in the YAML view in the cloud console, but it’s not mentioned in the API docs https://cloud.google.com/run/docs/reference/rest/v2/projects.locations.services#Service

  2. firebase-tools shouldn’t do a GET and a PUT. Instead it should use a PATCH request to to add the tag https://cloud.google.com/run/docs/reference/rest/v2/projects.locations.services/patch

[REQUIRED] Environment info

firebase-tools:

❯ npm firebase-tool --version
10.6.0

Platform: Fedora / Ubuntu

[REQUIRED] Test case

Deployment of Next app using Firebase Webframeworks fails due to runtimeClassName HTTP Error: 400

[REQUIRED] Steps to reproduce

  1. Create a Next.js project
  2. Execute firebase experiments:enable webframeworks
  3. Execute firebase deploy --project xxxx --debug

[REQUIRED] Expected behavior

Update a new version next.js app

[REQUIRED] Actual behavior

Error:

code":400,"message":"spec.template.spec.runtimeClassName: When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":
[2024-04-26T16:25:42.191Z] <<< [apiv2][body] PUT https://run.googleapis.com/v1/projects/770880274560/locations/us-east1/services/ssrclickmenudevfirebase {"error":{"code":400,"message":"spec.template.spec.runtimeClassName: When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"spec.template.spec.runtimeClassName","description":"When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update"}]}]}}
[2024-04-26T16:25:42.194Z] FirebaseError: HTTP Error: 400, spec.template.spec.runtimeClassName: When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update
    at responseToError (/usr/local/lib/node_modules/firebase-tools/lib/responseToError.js:49:12)
    at RetryOperation._fn (/usr/local/lib/node_modules/firebase-tools/lib/apiv2.js:297:77)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Same situation as @Lzak deploying React + Next project.

Also running into this issue when trying to deploy my React + Next project. Error: Failed to replace Run service projects/XXXXXX/locations/us-east1/services/ssrXXXXXX

[REQUIRED] Environment info

Platform: macOS Ventura 13.5

package.json

{
    "firebase": "10.11.1",
    "firebase-admin": "^11.8.0",
    "firebase-tools": "^13.7.5",
    ...
}

[REQUIRED] Test case

Deployment of React+Next app using Firebase Webframeworks fails due to runtimeClassName HTTP Error: 400

[REQUIRED] Steps to reproduce

Create a Next.js project Execute firebase experiments:enable webframeworks Execute firebase deploy --debug

[REQUIRED] Expected behavior

Deploy the project along with the SSR function.

[REQUIRED] Actual behavior

[2024-04-27T16:58:33.786Z] <<< [apiv2][status] PUT https://run.googleapis.com/v1/projects/XXXXXXXXX/locations/us-east1/services/ssrXXXXXXXX 400
[2024-04-27T16:58:33.786Z] <<< [apiv2][body] PUT https://run.googleapis.com/v1/projects/XXXXXXXXX/locations/us-east1/services/ssrXXXXXXXX {"error":{"code":400,"message":"spec.template.spec.runtimeClassName: When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"spec.template.spec.runtimeClassName","description":"When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update"}]}]}}
[2024-04-27T16:58:33.846Z] FirebaseError: HTTP Error: 400, spec.template.spec.runtimeClassName: When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update
    at responseToError (/Users/Lzak/.nvm/versions/node/v16.16.0/lib/node_modules/firebase-tools/lib/responseToError.js:49:12)
    at RetryOperation._fn (/Users/Lzak/.nvm/versions/node/v16.16.0/lib/node_modules/firebase-tools/lib/apiv2.js:299:77)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Error: Failed to replace Run service projects/XXXXXXXXX/locations/us-east1/services/ssrXXXXXXXX

Hey folks, thanks for all the information you shared, and apologies for the delay. Thanks @benediktarnold and @phminella for sharing your workarounds. I was able to reproduce the issue when setting the region to europe-west3 with pintags enabled. Let me try to bring someone from our team to look into this and provide more context.

Another workaround: Use us-central1 or europe-west1 as the region for frameworksBackend. I tested both and didn’t have the problem. Initially I used europe-west3 and had the error.

Explanation: The cloud run admin api behaves different depending on the region. Some regions return the annotation run.googleapis.com/base-images for the GET request and some don’t. So far I tested:

  • europe-west3 (error)
  • europe-west1 (works)
  • us-central1 (works)

Have the same issue when deploying Cloud Functions 2nd generation.

Same issue with Nextjs .Failed to replace Run service projects

Same error here… for those in need to deploy immediately, disabling pintags firebase experiments:disable pintags before deploying should make it go through.

This works for me, thank you.

Another workaround: Use us-central1 or europe-west1 as the region for frameworksBackend. I tested both and didn’t have the problem. Initially I used europe-west3 and had the error.

Explanation: The cloud run admin api behaves different depending on the region. Some regions return the annotation run.googleapis.com/base-images for the GET request and some don’t. So far I tested:

  • europe-west3 (error)
  • europe-west1 (works)
  • us-central1 (works)

report:

  • asia-east1 (error)

Hello,

I wanted to provide an update on my previous issue regarding the deployment of my Angular SSR Cloud Function in the europe-west3 region. Today, I retried firebase experiments:disable pintags, and unlike yesterday, it worked successfully. I was able to deploy my function without encountering the error from before.

Thank you for the support, and I hope this information might be helpful to others experiencing similar issues.

Have the same issue when deploying Cloud Functions 2nd generation.

I get this issue when trying to add a Cloud SQL connection to Cloud Runs - this was working last week, seems like there was a change that impacts Cloud Run (Annotation logic)? This also seems to affect firebase then

Same issue, any solutions?

Same issue

spec.template.spec.runtimeClassName: When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update

Fail to finalize version

@Camille-D I got the same “Invalid Request. Violations: {runtime_update_policy=Base image update feature is not applicable to 2nd Gen functions.}” error while deploying 2nd Gen functions since a few minutes.

This not only applies to functions related to the Webframeworks but to all 2nd Gen Cloud Functions.

Does anyone have a fix yet?

Another workaround: Use us-central1 or europe-west1 as the region for frameworksBackend. I tested both and didn’t have the problem. Initially I used europe-west3 and had the error.

Explanation: The cloud run admin api behaves different depending on the region. Some regions return the annotation run.googleapis.com/base-images for the GET request and some don’t. So far I tested:

  • europe-west3 (error)
  • europe-west1 (works)
  • us-central1 (works)

Good catch! I have the error with northamerica-northeast1 and us-east1.

Same issue in sveltekit deployment as well

Same issue as @Lzak from 14 hours ago.