Skip to content

HTTP.toEvent is lacking the cloudevents specification and accepts invalid objects #597

Open
@mhay-at-dvelop

Description

@mhay-at-dvelop

Describe the Bug
I'm trying to implement a rest-api for nodejs application with this sdk-javascript. when using HTTP.toEvent Method it returns an Object even when its semantically invalid compared to the cloudevents specification. So for example if you not supply the "type" property the method returns a cloud-event object with a type property which is undefined. Also if not supplying the specversion property it sets this property in result with a default value "1.0". Specification says that this property must be supplied, not that it is optional with a default value.
In my mind the method must not return a cloudevent object if it conflicts with the cloudevent specification.

Steps to Reproduce

  1. Use example "Receiving events" from sdk-javascript documention
  2. Use Postman to send a cloudevent with following structure (without specversion and type):
    {
    "source":"Source as a URI spec#123",
    "id":"b25e2717-a470-45a0-8231-985a99aa9416",
    "time":"2019-11-06T11:08:00Z",
    "datacontenttype":"application/json",
    "data":{
    "much":"wow"
    }
    }
  3. Check returning result from HTTP.toEvent. Resulting object has now a default "specversion" property with value 1.0 and an "type" property with value "undefined".

Expected Behavior
Should return error or throw exception in the mentioned cases .

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions