Logger does not include jsonPayload if object property value is undefined
[REQUIRED] Version info
node: 16.14.2
firebase-functions: 4.0.1
firebase-tools: 11.15.0
firebase-admin: 11.2.0
[REQUIRED] Test case
export const someFunction = functions.https.onRequest(async (req, res) => {
functions.logger.error('Error 1', {
foo: 'bar',
}
functions.logger.error('Error 2', {
foo: null,
}
functions.logger.error('Error 3', {
foo: undefined,
}
res.status(200).send()
})
[REQUIRED] Steps to reproduce
Deploy and call any type of cloud function, http or other, and log an error with a message and an object containing a property with a value of undefined.
[REQUIRED] Expected behavior
We expect the jsonPayload to describe the object properties in every above case, including when the object property is undefined.
[REQUIRED] Actual behavior
Log 1
jsonPayload: {
foo: "bar"
message: "Error 1 <stack>"
}
Log 2
jsonPayload: {
foo: null
message: "Error 2 <stack>"
}
Log 3
textPayload: "Error 3 <stack>"
Log 3 does not include jsonPayload. We want it to specify foo: undefined, as that is important information to us.
Were you able to successfully deploy your functions?
Yes, there are no issues with deployment.
There is no such thing as undefined in JSON. What results were you expecting?
I'm not 100% sure what the best solution would be, but the fact that jsonPayload was missing entirely was very confusing before I discovered the property value was undefined. I know having a string value of "undefined" would potentially have its own problems but I have to think there is a better solution than omission of the entire payload.