firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

Fail fast on initializing with a different project's databaseUrl

Open snarfed opened this issue 3 years ago • 1 comments

Originally filed in https://github.com/firebase/firebase-functions/issues/1191 and on StackOverflow.

Hi all! Thanks for Firebase, it's great!

I recently tried to set up a Firebase Cloud Function to trigger on a Realtime Database owned by a different project: the Hacker News API. I passed databaseUrl: https://hacker-news.firebaseio.com/ to admin.initializeApp(), and it deployed fine, but it never triggered.

I eventually learned that Firebase just doesn't support triggering across projects like this. Fair enough. Could you consider failing fast and reporting an error in this case? That would have saved me a fair amount of debugging.

Code below. Thanks in advance!

const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp({databaseUrl: 'https://hacker-news.firebaseio.com/'})

exports.itemUpdated = functions.database.ref('/v0/item/{id}').onCreate((snapshot, context) => {
      functions.logger.log('Item: ', context.params.id, snapshot.val())
      return null
})

snarfed avatar Aug 16 '22 19:08 snarfed

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Aug 16 '22 19:08 google-oss-bot