Skip to content

CloudEvent data in Array format throws a ValidationError #280

@lance

Description

@lance

Describe the Bug

When creating or receiving a CloudEvent, if the data is in the form of an Array - which is valid JSON - we get a validation error.

Steps to Reproduce

  1. use new CloudEvent() to create an event with the data property as an array. For example:
const ce = new CloudEvent({ source: '/test', type: 'example', data: [ 1, 2, 3 ] });

That will produce:

   TypeError: invalid payload
      at Object.validateV1 (src/event/spec.ts:14:11)
      at CloudEvent.validate (src/event/cloudevent.ts:178:16)
      at new CloudEvent (src/event/cloudevent.ts:121:10)

Expected Behavior

No error thrown.

Additional context

The schema seems to have wrongly typed data here https://github.com/cloudevents/sdk-javascript/blob/master/src/event/schemas.ts#L12-L14 and here https://github.com/cloudevents/sdk-javascript/blob/master/src/event/schemas.ts#L91-L93

Metadata

Metadata

Assignees

Labels

module/libRelated to the main source codespec/0.3Support for spec v0.3spec/1.0Issues related to the CE specificationtype/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions