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
{{ message }}
Repository navigation
SHOULD throw if subject is empty string (parsed from structured content mode)? #382
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: "".
Activity
lance commentedon Mar 5, 2021
Hmm, since
subjectis 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 asce-subject: "".github-actions commentedon Apr 5, 2021
This issue is stale because it has been open 30 days with no activity.