Skip to content
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

[v9/auth] Blocking Function Errors in JS SDK do not provide full error message/info from blocking function #5386

Closed
tannerlinsley opened this issue Aug 26, 2021 · 1 comment · Fixed by #5423
Assignees

Comments

@tannerlinsley
Copy link

[REQUIRED] Describe your environment

  • Operating System version: any
  • Browser version: any
  • Firebase SDK version: 9.0.0-beta.8
  • Firebase Product: auth

[REQUIRED] Describe the problem

When using v9 and when following the documentation for blocker functions here to send a custom error message to the Firebase Auth SDK, error messages are malformed and do not contain the data that the docs claim they should.

Here is the blocker function we are running:

const gcipCloudFunctions = require('gcip-cloud-functions');
const authClient = new gcipCloudFunctions.Auth();

exports.beforeCreate = authClient.functions().beforeCreateHandler((user, context) => {
  throw new gcipCloudFunctions.https.HttpsError('invalid-argument', `this is a custom error message`);
})

This is the network error that is received in the browser after the blocker function errors:

{
  "error": {
    "code": 400,
    "message": "BLOCKING_FUNCTION_ERROR_RESPONSE : HTTP Cloud Function returned an error: {\"error\":{\"code\":400,\"message\":\"this is a custom error message\",\"status\":\"INVALID_ARGUMENT\"}}",
    "errors": [
      {
        "message": "BLOCKING_FUNCTION_ERROR_RESPONSE : HTTP Cloud Function returned an error: {\"error\":{\"code\":400,\"message\":\"this is a custom error message\",\"status\":\"INVALID_ARGUMENT\"}}",
        "domain": "global",
        "reason": "invalid"
      }
    ]
  }
}

This is the error (serialized) that the client SDK receives after the failed attempt to create a user:

react_devtools_backend.js:2850 {
  "code": "auth/blocking-function-error-response",
  "customData": {},
  "name": "FirebaseError"
}

As you can see, the SDK error does not contain the same information as is visible in the network tab.

cc: @derekperkins

@xil222
Copy link

xil222 commented Aug 31, 2021

Hey @Feiyang1 , @sam-gc could anyone of you cc me as well once the internal bug is filed? I am also working on blocking function, and receiving a similar issue for blocking function in link.
I might be able to help when I have time, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants