New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Error: The incoming JSON object does not contain a client_email field" after upgrading to 7.0.2 #1451
Comments
Relevant stackoverflow post: https://stackoverflow.com/questions/56789424/the-incoming-json-object-does-not-contain-a-client-email-field |
@noelmansour thanks so it seems like something between |
Looks like that error comes from this library: googleapis/google-auth-library-nodejs#137 |
Am also experiencing this issue since 7.0.2 |
Just upgraded to 7.0.2, seeing this as well. Checked my account credentials and the |
Could someone share the code of a function they're trying to run in the emulator that fails with this error? The simpler the better. |
@samtstern The following code fails for me: import * as admin from 'firebase-admin';
admin.initializeApp();
import * as functions from 'firebase-functions';
export const testFunction = functions.https.onRequest(async (req, res) => {
const request = await admin.firestore().doc('test/123').get();
return request.ref.set({ test: 'random' })
.then(() => res.send('ok!'))
.catch((err) => res.status(500).send('error'));
}); It only works if I set a service account when calling // this works
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
}); |
@wceolin thanks for that! Can you run the following inside your functions directory?
This is my result (and everything works for me):
|
So I am walking my way up the error stack trace and in this function: We have this branching: async _getCredentials(opts: ClientStubOptions) {
if (opts.sslCreds) {
return opts.sslCreds;
}
const grpc = this.grpc;
const sslCreds = grpc.credentials.createSsl();
const client = await this.auth.getClient();
const credentials = grpc.credentials.combineChannelCredentials(
sslCreds,
grpc.credentials.createFromGoogleCredential(client)
);
return credentials;
} In my code
It's the other branch which tries to assemble credentials and causes problems. Now I need to figure out why my code goes one way and yours goes another way. |
@wceolin could you reach into your Thank you for your help so far! |
@samtstern Not sure if this helps, but I did a bunch of tweaking with my package.json and node_modules over the weekend. I no longer have the issue on 7.0.2. The I nuked my node_modules directory over the weekend so I wonder if that's related. |
@noelmansour thanks for that note, explains why I can't reproduce in a clean setup. |
@noelmansour I also tried deleting my @noelmansour this is what I got from the {
"clientConfig": {},
"port":443,
"servicePath":"firestore.googleapis.com",
"credentials":{},
"projectId":"my-test-project",
"firebaseVersion":"8.2.0",
"libName":"gccl",
"libVersion":"2.2.3 fire/8.2.0",
"scopes":[
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/datastore"
]
} |
@wceolin thanks that's extremely helpful because this is what mine looks like (and what it should look like): {
"clientConfig":{},
"port":8080,
"servicePath":"localhost",
"credentials":{},
"projectId":"fir-dumpster",
"firebaseVersion":"8.2.0",
"libName":"gccl",
"libVersion":"2.2.3 fire/8.2.0",
"service":"firestore.googleapis.com",
"sslCreds":{
"callCredentials": {}
},
"customHeaders":{
"Authorization":"Bearer owner"
},
"scopes":[
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/datastore"
]
} As you can see your client is still trying to access production, and then it fails because the functions emulator is not authorized to do so. Are you also running the firestore emulator? Is your goal to write to the firestore emulator or do you actually want to write to production firestore? |
OH I WAS FINALLY ABLE TO REPRODUCE THIS! If I run I see this log message:
Which is no longer exactly right (the error is about client_email) but the detection is still correct. Do others here see this warning as well? |
Here's some more info that may help. Over the weekend, I had also explicitly set the firestore emulator env variable in my .zshrc:
When I remove it, I get the error. And this is with the command |
@noelmansour can you run that command with |
@samtstern sometimes I was using the emulator to serve an HTTP function locally which sets some data in production (usually to do some data migration). I'm using:
I'm not sure if it was supposed to work like that (allowing us to write data to production) but it used to work. 😅 |
@wceolin it wasn't supposed to work like that with bare But I am glad to know where this error comes from now! |
@samtstern Just to confirm, run |
Correct!
…On Mon, Jul 1, 2019, 12:28 PM Noel Mansour ***@***.***> wrote:
@samtstern <https://github.com/samtstern> Just to confirm, run firebase
emulators:start --debug with the FIRESTORE_EMULATOR_HOST not set, correct?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1451?email_source=notifications&email_token=ACATB2WV27VPIODNLGFS4TLP5JLGBA5CNFSM4H4GTWI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY7DO2Q#issuecomment-507393898>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACATB2WG4EAD5KU7YRB5AUTP5JLGBANCNFSM4H4GTWIQ>
.
|
Here it is. FYI I removed the project-id from this line (don't think it matters): |
Also worth mentioning, without exporting the env variable, firebase-tools@7.0.1 gives me this error:
|
Thanks @noelmansour for those logs. Would you mind showing your functions code as well? |
It's a little tricky because I'd rather not share all my functions, and I don't have time right now to verify that in isolation this will repro the error, but here's the hello function I've been running: index.ts: require('./common'); // this should always be first in this file
export * from './debug'
// other exports for other functions common.ts: import * as admin from 'firebase-admin';
export const app = admin.initializeApp(); debug.ts: import * as admin from 'firebase-admin';
import * as functions from 'firebase-functions';
import {app} from "./common";
export const hello = functions.https.onRequest(async (req, resp) => {
const firestore = app.firestore();
const users = await firestore.collection('users').get();
console.log('empty users collection? ' + users.empty);
resp.sendStatus(200);
}); package.json: {
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase functions:shell",
"emulators": "npm run build && firebase emulators:start",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "8"
},
"main": "lib/index.js",
"dependencies": {
"@google-cloud/tasks": "^1.1.0",
"@types/jsonwebtoken": "^8.3.2",
"@types/request-promise": "^4.1.42",
"firebase-admin": "^8.2.0",
"firebase-functions": "^3.0.2",
"request": "^2.88.0",
"request-promise": "^4.2.4"
},
"devDependencies": {
"tslint": "^5.12.0",
"typescript": "^3.2.2"
},
"private": true
} |
@noelmansour thank you! That just revealed a bug to me. These two things should be identical but are not: Option 1
Option 2
|
Thanks phtn, appreciated - I followed your instructions but I now get the error
Weirdly when I run 'firebase deploy' everything is working on: 'https://europe-west1-myapp.cloudfunctions.net/api/... - just NOT on localhost? |
A combo of these two responses worked! Thanks again for helping. |
serviceAccountKey.json should be in the |
Thanks again (for being so patient!). My serviceAccountKey.json is in the /functions folder (See screen-grab on link below). It appears there are three ways to initilizeApp...I have tried all three of these individually and none of them seem to work - I have a feeling this is going to be something crazy simple I am missing. D |
We are having the same issue on our end. We're initializing firebase under this model: const firebaseInstance = admin.initializeApp() Let me know if we can provide anything to help track this down. |
Everyone on this thread. We discovered a solution. We downgraded firebase-tools from 7.0.2 to 7.0.1 and received an entirely different error (something about not being able to load default credentials). So we continued by running:
This fixed our issue |
@ryanhornberger you could work around your issue by doing: const firebaseInstance = admin.initializeApp()
const firestoreInstance = admin.firestore() // I changed this line I have a fix for that coming in #1459 |
@samtstern thank you! |
This works for me. I initially upgraded firebase-tools to 7.1, I got the 'same error' when I run 'firebase serve' in my local. However it's working fine if I deployed to firebase. Downgraded to 7.0.1 works for me in my local. |
Same issue with 7.1 |
We are working on a fix, but it's not ready yet: |
I'm stuck with this please, any way out? |
downgrading to 7.0.1 did`t help for me |
A fix for this was merged into #1479 and will be included in the next release (so |
Hey @samtstern, not sure if it's something I'm doing incorrectly, or perhaps a couple of new issues, but I've noticed a couple of things running the tools off the latest master (dad143c). First, I get the following warning when running
Even though earlier in the command I can see that it starts the emulator:
It's not actually updating the production firestore DB. Maybe just a false negative? The other issue is that I'm still getting the error. I didn't set
I'm initializing the admin sdk without any parameters using |
@noelmansour thanks for reporting this (and for trying Almost certainly a false negative, but an important one that we need to fix. |
It's pretty minimal as it's just exporting from other files: import * as admin from 'firebase-admin';
// this should happen before any function runs
admin.initializeApp();
export * from './authFunctions';
export * from './fitbit';
export * from './sleep'
export * from './scheduler';
export * from './debug'
export {scheduleFunction} from "./scheduler"; |
Actually, it seems to be an issue with my test setup. When running |
@noelmansour what do your tests look like? Also could you file a new issue to discuss this so we don't spam everyone on this thread> |
Yes, of course. My apologies. #1530 opened |
Could you pls tell how to downgrade firebase version? My current version is 7.0.2 then i tried installing npm i firebase-tools@7.0.0 -g this. but still my version is 7.0.2 . how to downgrade pls help? |
The full fix for this issue has been released in
If you are still experiencing a similar bug on that version, please open a new issue. |
[REQUIRED] Environment info
firebase-tools: 7.0.2
Platform: Oracle Linux Server 7.6, Node 10.15
[REQUIRED] Test case
emulate https function with "firebase-admin": "^8.2.0", "firebase-functions": "^3.0.2"
[REQUIRED] Steps to reproduce
run any https function with firebase functions:shell
[REQUIRED] Expected behavior
no error (firebase-tools 7.0.0 throws no error)
[REQUIRED] Actual behavior
Sent request to function.
The text was updated successfully, but these errors were encountered: