serverless-offline
serverless-offline copied to clipboard
TypeError: Cannot destructure property 'responseParameters' of 'chosenResponse' as it is undefined
Bug Report
Running a serverless app with "sls offline" and making a request to the app's REST API endpoint results in the following message:
Debug: internal, implementation, error
TypeError: Cannot destructure property 'responseParameters' of 'chosenResponse' as it is undefined.
at file:///home/app/sls-offline-debug/node_modules/serverless-offline/src/events/http/HttpServer.js:657:15
at async exports.Manager.execute (/home/app/sls-offline-debug/node_modules/@hapi/hapi/lib/toolkit.js:60:28)
at async Object.internals.handler (/home/app/sls-offline-debug/node_modules/@hapi/hapi/lib/handler.js:46:20)
at async exports.execute (/home/app/sls-offline-debug/node_modules/@hapi/hapi/lib/handler.js:31:20)
at async Request._lifecycle (/home/app/sls-offline-debug/node_modules/@hapi/hapi/lib/request.js:370:32)
at async Request._execute (/home/app/sls-offline-debug/node_modules/@hapi/hapi/lib/request.js:280:9)
(If I click "http://localhost:3000/dev/products" on the console, I see the error message above on the console)
Current Behavior
Just described above
Sample Code
I've made a repo for this error: https://github.com/Hiroki111/sls-offline-debug
If you run this app by "sls offline", you should be able to see the same error.
Expected behavior/code
"GET | http://localhost:3000/dev/products" return an array of object and the status code is 200.
Environment
-
serverless
version: [v3.26.0] -
serverless-offline
version: [^12.0.4] -
node.js
version: [e.g. v16.14.2] -
OS
: [Ubuntu 20.04 (WSL2)]
Possible Solution
Additional context/Screenshots
I think this problem is related to the use of.
responses: {
200: {
description: 'This is a success response',
bodyType: 'Product',
},
},
where did you find this in the serverless documentation?
Workaround:
Adding default response
responses: {
default: {},
200: {
description: 'This is a success response',
bodyType: 'Product',
},
},
@Hiroki111 Fixed in v13.3.4