-
Notifications
You must be signed in to change notification settings - Fork 886
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
Throwing HttpsError('ok') leads to internal exception in httpsCallable #3996
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
We do treat error code |
@Feiyang1 Just for info, here's the documentation: https://firebase.google.com/docs/functions/callable-reference#request_body:
I mainly filed the bug just because httpsError("ok") has documented behavior which HttpsCallable seems to not adhere to. Our use case is not very vital as we have an easy workaround. We have a validation function at the top of every Firebase Function that validates our request data. If it finds an error, it throws an httpsError and the Firebase Function automatically terminates. In one special case, the request data will contain a value that asks the Firebase Function for it's version number. In that case, we want the Firebase Function to immediately terminate (like the error cases) but succeed, so we throw HttpError("ok", something, something2); Here's an example:
Then, the client can handle this success case in the success flow. However, the workarounds are pretty easy: 1) We can just throw some HttpsError other than "ok" and just handle the version number in the catch() error handling code path. This isn't perfect as semantically, the code reads as an error case. Or, we terminate the Firebase Function as usual:
HttpsError("ok") is just a neat hack that works perfectly for us, since it acts to terminate the Firebase Function from inside a helper function. The only problem is that HttpsCallable trips on httpsError("ok") and converts it into a meaningless "internal" error. |
Thanks for explaining your use case! And thanks for the link to the reference doc. I saw this in the doc:
It sounds like the client SDK should treat |
We can update the condition here to also check for the error that should have been parsed in the previous block:
|
Yes. Doug Stevenson suggested I file a bug.
[REQUIRED] Describe your environment
[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:
Relevant Code:
The text was updated successfully, but these errors were encountered: