middyjs / middy

🛵 The stylish Node.js middleware engine for AWS Lambda 🛵

Home Page:https://middy.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Cannot read properties of undefined (reading 'Accept')

phawxby opened this issue · comments

https://github.com/middyjs/middy/blob/f6c152404d7c714b365ad60839ef3ea6b6d554eb/packages/http-response-serializer/index.js#L12C26-L12C26

It appears that normalizeHttpResponse() in the event of undefined or an empty object creates new objects and returns them. This function is relying on side effects for the changes so if new objects are created they're not seen. The result is that if an undefined object is passed in you get an error. It should probably be more like

request = normalizeHttpResponse(request);