Skip to content

Error message/code not passed into error #531

@Ivkaa

Description

@Ivkaa
  • Operating System version: macos mojave 10.14.4
  • Firebase SDK version: latest - 7.3.0
  • Library version: 7.3.0
  • Firebase Product: auth

Describe the problem

Steps to reproduce:

Call:
await firebase.auth().verifySessionCookie(token, true);
with invalid token
ex.
await firebase.auth().verifySessionCookie("a", true);

Which throws error

TypeError: Cannot read property 'code' of undefined
      at FirebaseAuthError.FirebaseError.toJSON (/Users/ewe/Projects/seasy/api/node_modules/firebase-admin/lib/utils/error.js:73:24)
      at JSON.stringify (<anonymous>)
      at prettyJSONStringify (/Users/ewe/Projects/seasy/api/node_modules/apollo-server-core/dist/runHttpQuery.js:258:17)
      at throwHttpGraphQLError (/Users/ewe/Projects/seasy/api/node_modules/apollo-server-core/dist/runHttpQuery.js:26:42)
      at Object.<anonymous> (/Users/ewe/Projects/seasy/api/node_modules/apollo-server-core/dist/runHttpQuery.js:66:28)
      at Generator.next (<anonymous>)
      at fulfilled (/Users/ewe/Projects/seasy/api/node_modules/apollo-server-core/dist/runHttpQuery.js:4:58)
      at process._tickCallback (internal/process/next_tick.js:68:7)

(the code has line this.code and obviously this === undefined)

If I inspect value of errorInfo in FirebaseError

function FirebaseError(errorInfo) {
   console.log(errorInfo)
   ...rest of the code
}

the value contains the right error message and code, so the error is not being thrown as it should but instead there is the error above when handling the error

{ code: 'auth/argument-error',
  message:
   'Decoding Firebase session cookie failed. Make sure you passed the entire string JWT which represents a session cookie. See https://firebase.google.com/docs/auth/admin/manage-cookies for details on how to retrieve a session cookie.' }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions