You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the Bug Spec states that the subject MUST be a non-empty string. In structured content mode HTTP.toEvent adds an empty subject string as undefined to the event and calling validate on the resulting event does therefore NOT throw.
In binary content mode, HTTP.toEvent adds the empty subject as subject: '' and a subsequent call on validate throws subject should NOT be shorter than 1 characters. This would be the correct behavior I assume.
Steps to Reproduce
Use the following snippet:
constevent=HTTP.toEvent({headers: {'Content-Type': 'application/cloudevents+json'},body: {id: '0815',specversion: '1.0',type: 'my.event.type',source: 'my.event.source',subject: ''}})// event has subject: undefinedevent.validate()// does not throw
Expected Behavior
event should have subject: '' and event.validate() should throw.
Additional context
property is the empty string here and therefore the parser is not executed
event should have subject: '' and event.validate() should throw.
Hmm, since subject is an optional attribute, it seems odd to throw if it's empty - even if the spec states that it should be a non-empty string. I would argue that the binary parser is wrong, and that it should not throw when receiving a header such as ce-subject: "".
Describe the Bug
Spec states that the
subject
MUST be a non-empty string. In structured content modeHTTP.toEvent
adds an empty subject string asundefined
to the event and callingvalidate
on the resulting event does therefore NOT throw.In binary content mode,
HTTP.toEvent
adds the empty subject assubject: ''
and a subsequent call onvalidate
throwssubject should NOT be shorter than 1 characters
. This would be the correct behavior I assume.Steps to Reproduce
Use the following snippet:
Expected Behavior
event should have
subject: ''
andevent.validate()
should throw.Additional context
property
is the empty string here and therefore the parser is not executedsdk-javascript/src/message/http/index.ts
Line 210 in 6be3b27
In general not sure if this should be an error on
HTTP.toEvent
already or only atvalidate
The text was updated successfully, but these errors were encountered: