Search code examples
firebasefirebase-storagequotagoogle-cloud-storage

RESOURCE_EXHAUSTED error when linking a GCS bucket to firebase (projects.buckets.addFirebase)


I have a script that creates a GCS bucket, links it to firebase and apply firebase rules on the bucket. Recently, I am running into this error that it cannot link the GCS bucket to firebase.

I am using the REST method projects.buckets.addFirebase to import the GCS bucket to firebase. https://firebasestorage.googleapis.com/v1beta/{bucket=projects/*/buckets/*}:addFirebase

The response from the API says that the resource exhausted.

{
  "error": {
    "code": 429,
    "message": "Resource has been exhausted (e.g. check quota).",
    "status": "RESOURCE_EXHAUSTED"
  }
}

So I checked the quota for firebase googleapis and it says the per minute usage has reached the limit. Okay, if that is the case, why doesn't it reset even after days of inactivity. I get the error every time I issue the request. If it is a per minute limit, why doesn't it reset the next minute? If I reach the per minute limit once, can't we use the service ever after?

enter image description here

I tried deleting the firebase security rules (storage and firestore) and still I get the same error.

I really don't understand the error and the quota it is linked to. How do I overcome this error? I am now not able to add any bucket to firebase. I know that we can increase the quota, but I might end up in the same situation when that limit also exceeds.


Solution

  • Finally, I was able to solve this issue.

    Looks like there were some orphaned buckets in the firebase side (that were soft-deleted) and they were causing the issue.

    In order to get rid of them I had to issue an API request to list the buckets. https://firebasestorage.googleapis.com/v1beta/{parent=projects/*}/buckets?pageSize=1000

    I assume that this cleared the orphaned buckets and after that I was able to create new gcs buckets and add them to firebase https://firebasestorage.googleapis.com/v1beta/{bucket=projects/*/buckets/*}:addFirebase

    I was not sure, if this was the issue and the solution to it. So, I tried the same in my another project which also had the same issue. And it worked.

    Let me know if this is the right solution, or something that worked out by luck :)