Throwing new functions.https.HttpsError on Firebase Cloud Function rejects as Internal Error on Client

It appears you aren't using the values listed here for the code parameter, as per the doc you linked. The value must be one of the canonical error codes for Google APIs. "failed-auth" or "invalid-email" for example aren't listed there. You may use "permission-denied" or "invalid-argument" instead.


I had the same issue. Novice here, so my attempt may be wrong but I was calling the functions locally and I couldn't get to the HttpsError.

So whilst doing the following:

const functionsGlobal = require('firebase-functions')
const functions = functionsGlobal.region('europe-west2')

I had to then get the HttpsError like this:

throw new functionsGlobal.https.HttpsError('failed-precondition',
    'The function must be called while authenticated.', 'hello')

Instead of:

throw new functions.https.HttpsError('failed-precondition', 
    'The function must be called while authenticated.', 'hello')

It works now but I would love for someone to explain why.