I am trying to use the Firestore trigger on_document_created_with_auth_context to get user info along with the document. However, the event data I receive is of type DocumentEventData instead of DocumentSnapshot. As a result, I cannot access the document fields using the get method. Instead, I receive the following error:
AttributeError: Unknown field for DocumentEventData: get
Steps to Reproduce
- Set up a Firestore trigger using
on_document_created_with_auth_context.
- Attempt to access document fields using the
get method on the event data.
- Observe the error mentioned above.
from firebase_functions.firestore_fn import AuthEvent, DocumentSnapshot, on_document_created_with_auth_context
@on_document_created_with_auth_context(document="*")
def document_created(event: AuthEvent[DocumentSnapshot]):
event.data.get("field")
Expected Behavior
The event data should be of type DocumentSnapshot, allowing access to document fields using the get method, similar to the behavior of the on_document_created trigger.
Actual Behavior
The event data is of type DocumentEventData, which does not support the get method, resulting in an AttributeError.
Additional Information
When using the on_document_created trigger, the event data is of type DocumentSnapshot, and I can access document fields without any issues. However, with on_document_created_with_auth_context, the event data type is DocumentEventData, leading to the error.
Is this the intended behavior, or should the event data be of type DocumentSnapshot similar to on_document_created? If not, how should this be resolved?
I am trying to use the Firestore trigger
on_document_created_with_auth_contextto get user info along with the document. However, the event data I receive is of typeDocumentEventDatainstead ofDocumentSnapshot. As a result, I cannot access the document fields using thegetmethod. Instead, I receive the following error:Steps to Reproduce
on_document_created_with_auth_context.getmethod on the event data.Expected Behavior
The event data should be of type
DocumentSnapshot, allowing access to document fields using thegetmethod, similar to the behavior of theon_document_createdtrigger.Actual Behavior
The event data is of type
DocumentEventData, which does not support thegetmethod, resulting in anAttributeError.Additional Information
When using the
on_document_createdtrigger, the event data is of typeDocumentSnapshot, and I can access document fields without any issues. However, withon_document_created_with_auth_context, the event data type isDocumentEventData, leading to the error.Is this the intended behavior, or should the event data be of type
DocumentSnapshotsimilar toon_document_created? If not, how should this be resolved?