Skip to content

structured events don't necessarily expect application/cloudevents+json #63

Closed
@cumason123

Description

@cumason123

Expected Behavior

Following crashes as CloudEvent attempts to unmarshall this as a binary event

from cloudevents.sdk.http_events import CloudEvent
import json
data = json.dumps({"id": "123", "source": "<source url>", "type": "com.sample.type", "specversion": "1.0"})
headers = {}
event = CloudEvent.from_http(data, headers)

Actual Behavior

from cloudevents.sdk.http_events import CloudEvent
import json
data = json.dumps({"id": "123", "source": "<source url>", "type": "com.sample.type", "specversion": "1.0"})
headers = {"Content-Type": "application/cloudevents+json"}
event = CloudEvent.from_http(data, headers)

We have not registered this content type with the IANA yet as seen here therefore we shouldn't expect all requests to have this header. We should instead check the http headers to determine whether event is structured or binary.

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