Open nohe427 opened 1 year ago
I want to run dart on Cloud Run and be able to respond to the Google Cloud Event sent by Eventarc on Firestore events. I generated all the dart protos after running this protoc -Iproto -Ithird_party/googleapis -Itmp/include --dart_out=../generated $(find . -name '*.proto')
.
Now my dart server is deserializing the envelope message (EntityWrittenEvent
) just fine, but for some reason the data message has no data.
A Dart SDK would be an absolute game changer for me, but for now I'm just going to have to do this myself.
@a-wallen - what proto are you using?
I think you want document written event from here: https://github.com/googleapis/google-cloudevents/blob/main/proto%2Fgoogle%2Fevents%2Fcloud%2Ffirestore%2Fv1%2Fevents.proto
Have you checked the cloud run headers received to verify the correct proto is being used?
@nohe427 thanks for the help - you'd think that the Firestore Envelope would be the correct proto to deserialize with, but it looks like Eventarc sends a Datastore Envelope instead.
here's the headers in my Cloud Run logs
ce-type: google.cloud.datastore.entity.v1.written
ce-dataschema: https://github.com/googleapis/google-cloudevents/blob/main/proto/google/events/cloud/datastore/v1/data.proto
plus the payload (base64 encoded so that I can paste it here)
CnYKWApAChcSFXp3bn5zdXJnZS1hcHAtYnVpbGRlchIlCg1jb25maWd1cmF0aW9uGhRoOGZpMllzSnFrYkFCMDBZUXJxbxoUCgVoZWxsbxILigEFd29ybGSYAQEqDAj7j5KuBhCYuaWhATIMCPuPkq4GEJi5paEB
The serialization is all wrong similar to this issue where the entire payload is just an unknown field.
Let me come up with a repro
I couldn't quite get it to reproduce the same way that it was with my hello world message
CnYKWApAChcSFXp3bn5zdXJnZS1hcHAtYnVpbGRlchIlCg1jb25maWd1cmF0aW9uGhRoOGZpMllzSnFrYkFCMDBZUXJxbxoUCgVoZWxsbxILigEFd29ybGSYAQEqDAj7j5KuBhCYuaWhATIMCPuPkq4GEJi5paEB
but this is the gist of what I have so far. https://github.com/a-wallen/firestore_triggers_cloud_run_protobuf
@a-wallen - What event are you using in eventarc / cloudrun? I used google.cloud.firestore.document.v1.written event in mine and when I deserialize the body to a proto it works. Is there a guide you are following?
Here is a screenshot from my cloud run instance to get the event type.
And then I used DocumentEventData proto.
Can you try calling this instead?
Apparently my "Hello, World" document has no values :). Are you using a test proto to debug locally? If so, could you send over that file? Also, what does your DocumentEventData.pb.dart
look like. Could you send that over so that I could run the two of ours through a diffchecker?
@a-wallen - To me, it looks like the issue is the event type. I remember having issues with that event and switched to the one I referenced in my above comment.
🥇@nohe427 that worked.
For some reason, this still doesn't work when I try to debug it locally with Postman though 🤷♂️
@a-wallen - Sorry, I am unfamiliar with using Postman for debugging. I would double check that you are sending the right headers and that you are sending the raw binary data (I saw you encode it to base64, are you remembering to decode it when you send it?)
Thanks for your help @nohe427 - I will be working on a barebones package for this https://pub.dev/packages/google_cloudevents_dart
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
I am interested in getting a
google-cloudevents-dart
repo. It appears that there is already a compiled events library that exists for golang, java, and kotlin. I would like to see one for dart.Describe the solution you'd like A clear and concise description of what you want to happen.
All protobufs compiled for dartlang.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Compiling these myself, but that feels like it takes a lot longer than I would like.
Additional context Add any other context or screenshots about the feature request here.