Skip to content

Firestore emulator doesn't emit all CloudEvent properties  #482

@dinko7

Description

@dinko7

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 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/<project_id>/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.<fn>
===== asynchronous gap ===========================
package:google_cloud/src/logging.dart 64:24                              _errorWriter.<fn>

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions