Mimic behavior from Node.js on KeyError
When a field does not exist on a document, the Python Cloud Function throws an error KeyError, but for the Node.js implementation it simply returns undefined (preferred). This is especially important for the on_document_written function, which might trigger for updates that need to be monitored, but if the document is created for the first time without fields yet, then this should not throw an error ideally.
Hi @Zaffer,
Thanks for reporting this issue! We’ve received it and are reviewing it. We’ll provide updates as soon as possible.
This could be due to the differences between these languages.
For example, in Python some_dict['invalid_property'] throws KeyError, when in Node some_dict['invalid_property'] returns undefined. Instead, you can probably use some_dict.get('invalid_property') (in Python) to get None returned.
Could you perhaps send over a code snippet that produces this issue, just to be certain?
Closing due to inactivity. Please feel free to reopen or create a new issue if you need further assistance.