Skip to content

Kafka event without headers #1113

@cavus700

Description

@cavus700

Hello,
I am not sure if this is an actual bug or if I miss something in the SDK but in my understanding this should work.

I am receiving a cloud event without any headers from a kafka instance:

------------------ Message -------------------

Topic Name: mytopic

------------------- key ----------------------

Key: mykey

------------------ headers -------------------

------------------- value --------------------

{
    "specversion" : "1.0",
    "type" : "com.example.someevent",
    "source" : "/mycontext/subcontext",
    "id" : "1234-1234-1234",
    "time" : "2018-04-05T03:56:24Z",
    "datacontenttype" : "application/json",
    "data" : {
        ... application data encoded in JSON ...
    }
}

-----------------------------------------------

The problem is that the SDK does not set a format for this message because the format is extracted from the headers here:
https://github.com/cloudevents/sdk-go/blob/main/protocol/kafka_sarama/v2/message.go#L47

This causes an error in the ToEvent() function here:
https://github.com/cloudevents/sdk-go/blob/main/v2/binding/to_event.go#L32

Is there a way to successfully parse an event like this or is this a bug in the SDK? The spec does not require a content-type header for structured events as I can see.

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