firebase-tools: 6.3.1
Platform: Ubuntu 18.04 LTS
loadFirestoreRules() parameter projectId string cannot have uppercase characters.
firebase.loadFirestoreRules({
projectId: "my-NON-LOWERCASE-project",
rules: fs.readFileSync("/path/to/firestore.rules", "utf8")
});
no error
2 UNKNOWN:
at Object.<anonymous>.exports.createStatusError (node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (node_modules/grpc/src/client_interceptors.js:1204:28)
at InterceptingListener.Object.<anonymous>.InterceptingListener._callNext (node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.Object.<anonymous>.InterceptingListener.onReceiveStatus (node_modules/grpc/src/client_interceptors.js:618:8)
at callback (node_modules/grpc/src/client_interceptors.js:845:24)
I believe this is actually a Google Cloud restriction. This documentation states that project ids are:
"""
The unique, user-assigned ID of the Project. It must be 6 to 30 lowercase letters, digits, or hyphens. It must start with a letter. Trailing hyphens are prohibited.
"""
I'll see if I can improve this error message, it looks quite opaque.
EDIT: Cool, if you look at the Firestore emulator's output you should see an error like "Invalid app id". There's a subtle issue in the code which means that error message isn't being displayed in the output of the loadFirestoreRules SDK method. Have a fix for that, internal tracking # is 124760010.
@ryanpbrewster thanks for the investigation. I'm now using lowercase project ids for my tests and it's fine, but as you said the error message is quite opaque. I took me a couple of hours to find out where this error was coming from. Hopefully a more explicit error message will save other users some precious time :wink:
Closing out this issue, but continuing to track the underlying bug in https://github.com/firebase/firebase-tools/issues/1256
We now emit a (hopefully) more informative message:
com.google.cloud.datastore.emulator.impl.util.WrappedStreamObserver onError
INFO: operation failed: Invalid app id
but it's still not handled very elegantly in the emulator code. In particular, it's emitted as an UNKNOWN error (grpc code 2).
Most helpful comment
Closing out this issue, but continuing to track the underlying bug in https://github.com/firebase/firebase-tools/issues/1256
We now emit a (hopefully) more informative message:
but it's still not handled very elegantly in the emulator code. In particular, it's emitted as an UNKNOWN error (grpc code 2).