Skip to content

Loose event validation #325

Closed
Closed
@lance

Description

@lance

Is your feature request related to a problem? Please describe.
Currently, when creating a CloudEvent instance, one of the final things that happens in the constructor before freezing the object is this.validate() is called. The validate() function will throw an exception if the event is invalid. This effectively means that there is no way to create an event that's invalid. In most cases, this is probably for the best. But what happens if you have a system with a known bug that's emitting invalid events, and some JavaScript service using this module is receiving them. There's no way to actually do that without forking this repo.

Describe the solution you would like to see

  • Optionally, don't call this.validate() in the constructor based on an added boolean parameter (strict: boolean = true by default).
  • Change Detector interface from feat: introduce Message, Serializer, Deserializer and Binding interfaces #324 to use an optional parameter for loose validation.
  • Change the Deserializer interface which converts from a Message to a CloudEvent to use an optional parameter for loose validation.

Additional context
This is all in the context of creating events manually, or deserializing an incoming Message into a CloudEvent. I haven't thought much about the serialization step. If a user manually creates an invalid event, and then serializes it to a Message, should that throw an exception? I think maybe it should, but interested in other's opinions.

Metadata

Metadata

Assignees

Labels

module/libRelated to the main source codetype/discussionIssues that need to be decided/debated/discussedtype/enhancementNew feature or requestversion/4.xIssues related to the 4.0 release of this library

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions