Open
Description
Yes. Doug Stevenson suggested I file a bug.
[REQUIRED] Describe your environment
- Operating System version: Windows 10
- Browser version: N/A (Using Node.js)
- Firebase SDK version: "firebase-admin": "^8.13.0",
- Firebase Product: Functions
[REQUIRED] Describe the problem
When a deployed, callable Firebase Function raises an HttpsError with error code "ok" the HttpsCallable on the caller receives an error with code "internal" and the message: "Response is missing data field."
Steps to reproduce:
- Deploy a callable Firebase Function that raises httpsError("ok");
- Call that function from a client using Node.js and HttpsCallable.
- Notice HttpsCallable's catch() gets triggered, with error containing: {"message":"Response is missing data field.","code":"internal"}. The documentation for HttpsError implies that "ok" should set the status to 200 and set response.error.
- Expected: HttpsCallable triggers the then() code path, with response.error containing the message given to httpsError.
- Guess: My guess is that HttpsError sets status to 200 and sets response.error. However, httpsCallable assumes that all 200's must have response.data set, so an exception is raised on the client. Unfortunately, this makes httpsError("ok") useless as there's no way to access any more information or distinguish httpsError("ok") from any other unhandled exceptions.
Relevant Code:
//Firebase function
exports.UpdateLobby = functions.https.onCall(async (data, context) => {
throw new functions.https.HttpsError('ok', 'test', 'test2');
}
//Node.js client code
var testFirebaseFunction = firebase.functions().httpsCallable("UpdateLobby");
return testFirebaseFunction().then(function(result) {
console.log(JSON.stringify(result));
return;
}).catch(function(error) {
console.log(JSON.stringify(error, Object.getOwnPropertyNames(error)));
}