Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google-cloudevents-dart #581

Open
nohe427 opened this issue Sep 20, 2023 · 10 comments
Open

google-cloudevents-dart #581

nohe427 opened this issue Sep 20, 2023 · 10 comments
Labels
api: eventarc Issues related to the googleapis/google-cloudevents API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@nohe427
Copy link

nohe427 commented Sep 20, 2023

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.

@nohe427 nohe427 added priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Sep 20, 2023
@product-auto-label product-auto-label bot added the api: eventarc Issues related to the googleapis/google-cloudevents API. label Sep 20, 2023
@a-wallen
Copy link

a-wallen commented Feb 8, 2024

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.

@nohe427
Copy link
Author

nohe427 commented Feb 8, 2024

@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?

@a-wallen
Copy link

a-wallen commented Feb 8, 2024

@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

@a-wallen
Copy link

a-wallen commented Feb 8, 2024

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

@nohe427
Copy link
Author

nohe427 commented Feb 8, 2024

@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.
Screenshot 2024-02-08 at 8 58 00 AM

And then I used DocumentEventData proto.

Screenshot 2024-02-08 at 9 00 22 AM

Can you try calling this instead?

@a-wallen
Copy link

a-wallen commented Feb 8, 2024

image
image
image

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?

@nohe427
Copy link
Author

nohe427 commented Feb 8, 2024

@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.

@a-wallen
Copy link

a-wallen commented Feb 8, 2024

🥇@nohe427 that worked.

image

image

For some reason, this still doesn't work when I try to debug it locally with Postman though 🤷‍♂️

@nohe427
Copy link
Author

nohe427 commented Feb 9, 2024

@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?)

@a-wallen
Copy link

Thanks for your help @nohe427 - I will be working on a barebones package for this https://pub.dev/packages/google_cloudevents_dart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: eventarc Issues related to the googleapis/google-cloudevents API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

2 participants