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
It seems that HTTP.toEvent, at least in BINARY mode, looks up extensions in header names starting with "ce-" prefix, however, it looks among original headers supplied in unknown case rather than sanitized headers which are lowercase.
So e. g. "Ce-myext: val" is ignored and doesn't make it into final event's "myext" field.
The text was updated successfully, but these errors were encountered:
$ node
Welcome to Node.js v20.5.0.
Type ".help" for more information.
> const { HTTP, httpTransport } = await import('cloudevents');
undefined
> const headers = {"Accept":"*/*","Ce-Id":"e2a8d1cb-7ef0-4efb-a24f-608c1715b196","Ce-Myext":"val","Ce-Source":"local","Ce-Specversion":"1.0","Ce-Type":"sometype","Content-Length":"82","Content-Type":"application/json","User-Agent":"curl/7.68.0"}
undefined
> HTTP.toEvent({ headers, body: "body"})
Sanitized headers: {"accept":"*/*","ce-id":"e2a8d1cb-7ef0-4efb-a24f-608c1715b196","ce-myext":"val","ce-source":"local","ce-specversion":"1.0","ce-type":"sometype","content-length":"82","content-type":"application/json","user-agent":"curl/7.68.0"}
Leftover sanitized headers: {"accept":"*/*","ce-myext":"val","content-length":"82","user-agent":"curl/7.68.0"}
{"id":"e2a8d1cb-7ef0-4efb-a24f-608c1715b196","time":"2023-09-28T08:25:48.053Z","type":"sometype","source":"local","specversion":"1.0","datacontenttype":"application/json","data":"body"}
Here, I expect that the resulting object contains value "val" at key "myext". Logs show the value of sanitizedHeaders, and I believe this is exactly where the .startsWith(__1.CONSTANTS.EXTENSIONS_PREFIX) check should happen, but instead it happens in headers, which is the original input headers in mixed case rather than lower case. So the "ce-" prefix check fails, because the actual prefix is "Ce-", and the extension is dropped.
It seems that
HTTP.toEvent
, at least inBINARY
mode, looks up extensions in header names starting with "ce-" prefix, however, it looks among original headers supplied in unknown case rather than sanitized headers which are lowercase.So e. g. "Ce-myext: val" is ignored and doesn't make it into final event's "myext" field.
The text was updated successfully, but these errors were encountered: