dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.19k stars 796 forks source link

TypeError: Cannot destructure property 'responseParameters' of 'chosenResponse' as it is undefined #1680

Closed Hiroki111 closed 4 months ago

Hiroki111 commented 1 year ago

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)

Screenshot 2023-04-09 172032

(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

Possible Solution

Additional context/Screenshots

Denis-String commented 1 year ago

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?

matricali commented 10 months ago

Workaround:

Adding default response

responses: {
          default: {},
          200: {
            description: 'This is a success response',
            bodyType: 'Product',
          },
        },
DorianMazur commented 4 months ago

@Hiroki111 Fixed in v13.3.4