serverless / dashboard

MIT License
26 stars 10 forks source link

SDK: Fix AWS Lambda Powertools error log parsing #767

Closed medikoo closed 1 year ago

medikoo commented 1 year ago

When browsing internal error reports. I found following:

{
  "message": "undefined is not iterable (cannot read property Symbol(Symbol.iterator))",
  "name": "TypeError",
  "stacktrace": "at handleErrorLog (/opt/nodejs/node_modules/@serverless/sdk/index.js:3622:34)\nat module2.exports.attemptParseStructuredLogAndCapture (/opt/nodejs/node_modules/@serverless/sdk/index.js:3662:13)\nat nodeStdout.write (/opt/nodejs/node_modules/@serverless/sdk/index.js:3698:9)\nat Console.log (/var/task/src/triggers/handle-db-change.js:201027:23)\nat Console._write (/var/task/src/triggers/handle-db-change.js:198701:19)\nat doWrite (/var/task/src/triggers/handle-db-change.js:118934:139)\nat writeOrBuffer (/var/task/src/triggers/handle-db-change.js:118925:5)\nat Writable.write (/var/task/src/triggers/handle-db-change.js:118846:11)\nat DerivedLogger.ondata (/var/task/src/triggers/handle-db-change.js:117942:20)\nat DerivedLogger.emit (node:events:513:28)",
  "type": "ERROR_TYPE_CAUGHT_SDK_INTERNAL"
}

It appears there's a bug when processing an AWS Lambda Powertools error log which was written without passing the error instance.

This patch ensures it's handled gently