Closed
Description
Related issues
#1426 which is supposed to be fixed by #1432 which hasn't been merged yet. I am raising this issue again, because without the merge&release of the fix I do no consider it "fixed".
[REQUIRED] Version info
node: v16.15.0
firebase-functions: 4.6.0
firebase-tools: 12.4.0
firebase-admin: 10.2.0
[REQUIRED] Test case
import * as functions from 'firebase-functions';
export let test = functions
.database
.ref('/test/{id}')
.onWrite((event, context) => console.log(event.after.child('nested/property').val()));
[REQUIRED] Steps to reproduce
Insert any value to realtime database at /test/123/whatever
[REQUIRED] Expected behavior
Calling event.after.child('nested/property').val())
should return null
(as it does prior to v4)
[REQUIRED] Actual behavior
TypeError: Cannot read properties of null (reading 'property') at DataSnapshot.val (/workspace/node_modules/firebase-functions/lib/common/providers/database.js:104:32)
Were you able to successfully deploy your functions?
Yes, this is a runtime error.
Footnote
Since the v4 rewrote the exists()
as a check to the result of val()
it is also affected. And it's really not clear to me how else to check if the nested property exists.
Metadata
Metadata
Assignees
Labels
No labels