[REQUIRED] Step 2: Describe your configuration
- Extension / Kit name:
firestore-bundle-builder (@firebase-function-kits/firestore-bundle-builder)
- Extension / Kit version:
0.0.2-rc.2
- Firebase Tools version:
15.29.0
- Configuration values:
- Clean GCP / Firebase project deployment where Cloud Firestore API was not previously enabled.
[REQUIRED] Step 3: Describe the problem
@firebase-function-kits/firestore-bundle-builder fails with HTTP 500 / 7 PERMISSION_DENIED: Cloud Firestore API has not been used in project ... before or it is disabled upon initial request on fresh projects because requiresAPI("firestore.googleapis.com", ...) is not declared in src/index.ts.
Steps to reproduce:
- Create a brand-new GCP/Firebase project (or test on a clean project where
firestore.googleapis.com is not pre-enabled).
- Scaffold and deploy
@firebase-function-kits/firestore-bundle-builder@0.0.2-rc.2 using Firebase CLI 15.29.0 with standard .env:
FUNCTION_DEFAULT_REGION=us-central1
BUNDLESPEC_COLLECTION=bundles
BUNDLE_STORAGE_BUCKET=<bucket-name>
STORAGE_PREFIX=bundles
firebase deploy --only functions --force
- Invoke the deployed function URL:
curl -i https://<function-url>/test-bundle
Expected result
firebase deploy identifies the required Google Cloud APIs via requiresAPI() and enables firestore.googleapis.com and storage.googleapis.com automatically during deployment. The function successfully queries Firestore and returns HTTP 404: Could not find bundle with ID test-bundle.
Actual result
firebase deploy completes without enabling firestore.googleapis.com because requiresAPI is missing from src/index.ts. When invoked, the function throws a runtime error and returns HTTP 500:
Unhandled error Error: 7 PERMISSION_DENIED: Cloud Firestore API has not been used in project <project-id> before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/firestore.googleapis.com/overview?project=<project-id> then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
at callErrorFromStatus (/workspace/node_modules/@firebase-function-kits/firestore-bundle-builder/node_modules/@grpc/grpc-js/build/src/call.js:32:19)
at Object.onReceiveStatus (/workspace/node_modules/@firebase-function-kits/firestore-bundle-builder/node_modules/@grpc/grpc-js/build/src/client.js:359:73)
at Object.onReceiveStatus (/workspace/node_modules/@firebase-function-kits/firestore-bundle-builder/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:327:181)
at /workspace/node_modules/@firebase-function-kits/firestore-bundle-builder/node_modules/@grpc/grpc-js/build/src/resolving-call.js:135:78
at process.processTicksAndRejections (node:internal/process/task_queues:85:11)
Proposed Fix:
In src/index.ts, declare the required APIs:
import { requiresAPI, requiresRole } from "firebase-functions/v2";
const REQUIRED_APIS = [
{
api: "firestore.googleapis.com",
reason: "Needed to read bundle specifications and documents from Cloud Firestore.",
},
{
api: "storage.googleapis.com",
reason: "Needed to read and write bundle file caches in Cloud Storage.",
},
];
for (const { api, reason } of REQUIRED_APIS) {
requiresAPI(api, reason);
}
[REQUIRED] Step 2: Describe your configuration
firestore-bundle-builder(@firebase-function-kits/firestore-bundle-builder)0.0.2-rc.215.29.0[REQUIRED] Step 3: Describe the problem
@firebase-function-kits/firestore-bundle-builderfails withHTTP 500/7 PERMISSION_DENIED: Cloud Firestore API has not been used in project ... before or it is disabledupon initial request on fresh projects becauserequiresAPI("firestore.googleapis.com", ...)is not declared insrc/index.ts.Steps to reproduce:
firestore.googleapis.comis not pre-enabled).@firebase-function-kits/firestore-bundle-builder@0.0.2-rc.2using Firebase CLI15.29.0with standard.env:Expected result
firebase deployidentifies the required Google Cloud APIs viarequiresAPI()and enablesfirestore.googleapis.comandstorage.googleapis.comautomatically during deployment. The function successfully queries Firestore and returnsHTTP 404: Could not find bundle with ID test-bundle.Actual result
firebase deploycompletes without enablingfirestore.googleapis.combecauserequiresAPIis missing fromsrc/index.ts. When invoked, the function throws a runtime error and returnsHTTP 500:Proposed Fix:
In
src/index.ts, declare the required APIs: