GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-dart
Firestore emulator doesn't emit all CloudEvent properties
- Dominant language
- Dart
- Stars
- 548
- Forks
- 49
- Avg merge
- 53m
- Merged PRs (30d)
- 1
Description
Hello there, thank you for making this!
I'm trying to test my Firestore triggered function (as shown in the `protobuf/rawevent` example) against the Firestore emulator.
I've managed to wire the emulator up the point where I can receive events to my function (by using [this](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/104#issuecomment-758954342) comment).
It seems that the emulator doesn't respect the CloudEvent interface.
The error I get on receiving the event to my function (`oncreatetodo` is the name of the function, I've changed it from default `function`):
```
Listening on :5001
2024-09-29T15:05:53.355871 0:31:05.307182 POST [400] /functions/projects//triggers/oncreatetodo
Could not decode the request as a structured-mode message. (400)
CheckedFromJsonException
Could not create `CloudEvent`.
There is a problem with "id".
Required keys are missing: id, source, specversion, type. (CheckedFromJsonException)
package:json_annotation/src/checked_helpers.dart 66:5 $checkedNew
package:json_annotation/src/checked_helpers.dart 30:10 $checkedCreate
package:functions_framework/src/cloud_event.g.dart 11:63 _$CloudEventFromJson
package:functions_framework/src/cloud_event.dart 57:7 new CloudEvent.fromJson
package:functions_framework/src/targets/cloud_event_targets.dart 105:23 _decodeValidCloudEvent
package:functions_framework/src/targets/cloud_event_targets.dart 80:10 _decodeStructured
===== asynchronous gap ===========================
package:functions_framework/src/targets/cloud_event_targets.dart 53:19 CloudEventWithContextFunctionTarget.handler
===== asynchronous gap ===========================
package:google_cloud/src/logging.dart 56:26 _handleBadRequest.
===== asynchronous gap ===========================
package:google_cloud/src/logging.dart 64:24 _errorWriter.
```
What would be the ideal solution to be able to test locally before I deploy?
`EmulatedCloudEvent` (all optional properties) that is used with a testing flag when running the function?
Firestore emulator respects CloudEvent interface so it's possible to test?
I'd appreciate any help!
Thanks
Contributor guide
Assessment
This issue has not been assessed yet.