Search code examples
firebasegoogle-cloud-platformgoogle-cloud-functionsfirebase-tools

`firebase deploy` error "Project has no namespace"


I tried running firebase deploy --only functions to upload a new Node.js cloud functions to firebases, and I am presented with this error:

⚠  functions: failed to update function projects/my-app/locations/us-central1/functions/fixGeoLocErr
Failed to update function projects/busfluence-app/locations/us-central1/functions/fixGeoLocErr
⚠  functions: HTTP Error: 400, Validation failed for trigger projects/my-app/locations/us-central1/triggers/sendnewoffernotification-890412: The request was invalid: generic::not_found: Project has no namespace.: invalid argument
⚠  functions:  failed to create function projects/busfluence-app/locations/us-central1/functions/sendNewOfferNotification
Failed to create function projects/busfluence-app/locations/us-central1/functions/sendNewOfferNotification

Functions deploy had errors with the following functions:
        sendNewOfferNotification(us-central1)
        fixGeoLocErr(us-central1)
i  functions: cleaning up build files...
Error: There was an error deploying functions:
- Error Failed to update function fixGeoLocErr in region us-central1
- Error Failed to create function sendNewOfferNotification in region us-central1

One of the already existing functions called fixGeoLocErr failed to update, and the new function I made called sendNewOfferNotification failed to upload.

The only reason why I can imagine this being an issue is that I recently added a new iOS app to firebase and have switched my project to use the new one. I didn't make any changes to any cloud function configurations after doing this. Could that be the problem?

I actually ended up completely reinstalling all the Firebase CLI tools, and also reinstalled node/npm on my machine to no avail. Any ideas?


Solution

  • This was the function that I was trying to deploy:

    const {onValueCreated} = require("firebase-functions/v2/database");
    const {logger} = require("firebase-functions");
    
    exports.sendNewNotification = onValueCreated("/transactions", (event) => {
        logger.log(`A new document was created`);
    });
    

    However, the onValueCreated function is made for the Real Time Database. In my project, I've been using Cloud Firestore, and RTDB isn't setup, hence the Project has no namespace error.

    Instead, I did this:

    const {onDocumentWritten} = require("firebase-functions/v2/firestore");
    const {logger} = require("firebase-functions");
    
    exports.sendNewNotification = onDocumentWritten("/transactions", (event) => {
        logger.log(`A new document was created`);
    });
    

    This uses the triggers for Cloud Firestore instead of RTDB.