GoogleCloudPlatform/functions-framework-php

Support or disable structured CloudEvents

Closed this issue · 2 comments

Current Behavior

You can activate the structured CloudEvent mode by setting Content-Type: application/cloudevents+json. However, CloudEventFunctionWrapper::fromRequest() does not lift the CloudEvent metadata to the top of the array object passed to CloudEvent::fromArray(). As a result, null values are passed to the CloudEvent constructor.

Expected Behavior

One of the following should be true:

  1. Structured Events work
  2. Structured events are explicitly rejected with a 400 error and guidance to use a binary event.

What metadata are you referring to? Can you provide a specific example?

After discussing with Adam, there are two types of Cloud Events, Binary and Structured. Right now, we handle Structured as if they are Binary, but what we should be doing is handling Structured differently - instead of saving the decoded JSON body of the request, we should use the JSON body to populate the Cloud Event.