-
Notifications
You must be signed in to change notification settings - Fork 70
Description
Describe the Bug
Extension attributes NOT following the naming convention (lowercase) are added to the event (no error thrown) but their value is added as undefined
.
Steps to Reproduce
Use the following snippet:
const event = HTTP.toEvent({
headers: {
'Content-Type': 'application/json',
'ce-id': '0815',
'ce-specversion': '1.0',
'ce-type': 'my.event.type',
'ce-source': 'my.event.source',
'ce-FOO': 'bar',
},
body: {}
})
Check the resulting event:
{
//...
id: '0815',
specversion: '1.0',
type: 'my.event.type',
source: 'my.event.source',
foo: undefined
}
Expected Behavior
I assume according to spec an error should be thrown if attributes not following the naming convention are passed. Alternatively, if they are still accepted, their value should be passed on to the event correctly.
Additional context
If decided to still pass the extension attribute, I think the problem lies somewhere here:
sdk-javascript/src/message/http/index.ts
Line 154 in 6be3b27
eventObj[header.substring(CONSTANTS.EXTENSIONS_PREFIX.length)] = headers[header]; |
header
has been sanitized (converted to lowercase, e.g. ce-foo
) which is not present as such in the headers
object (still original casing, e.g. ce-FOO
) and therefore undefined
is set as value.