Skip to content

functions.logger throws an exception when attempting to log null #716

Closed
@arthurM2x

Description

@arthurM2x

[REQUIRED] Version info

**node:**10

**firebase-functions:**3.7.0

**firebase-tools:**8.4.3

**firebase-admin:**8.10.0

[REQUIRED] Test case

import * as functions from 'firebase-functions'

// throws an exception
functions.logger.log('something', null)

[REQUIRED] Steps to reproduce

attempt to log null

[REQUIRED] Expected behavior

no exception

[REQUIRED] Actual behavior

exception thrown:

TypeError: Cannot read property 'constructor' of null
at entryFromArgs (/workspace/node_modules/firebase-functions/lib/logger.js:78:47)
at Object.log (/workspace/node_modules/firebase-functions/lib/logger.js:45:11)

https://github.com/firebase/firebase-functions/blob/master/src/logger.ts#L107
src/logger.ts:107
if (typeof lastArg == 'object' && lastArg.constructor == Object) {

typeof null -> "object"
so would be beneficial to add a null check there

Were you able to successfully deploy your functions?

Yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions