Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

500 Internal Server Error #547

Open
motiejuss opened this issue Jan 13, 2023 · 1 comment
Open

500 Internal Server Error #547

motiejuss opened this issue Jan 13, 2023 · 1 comment

Comments

@motiejuss
Copy link

motiejuss commented Jan 13, 2023

Bug Report

Description

Ran out of ideas where the actual error may be. I'm testing a very simple setup according to this article. Serverless builds fine and deploys fine.

When I test the endpoint from within API Gateway console, this is the output I get and everything seems to work fine:

Execution log for request e7fd711c-56f7-427e-8e58-87dbe5154193
Fri Jan 13 10:08:40 UTC 2023 : Starting execution for request: e7fd711c-56f7-427e-8e58-87dbe5154193
Fri Jan 13 10:08:40 UTC 2023 : HTTP Method: POST, Resource Path: /schedule
Fri Jan 13 10:08:40 UTC 2023 : Method request path: {}
Fri Jan 13 10:08:40 UTC 2023 : Method request query string: {}
Fri Jan 13 10:08:40 UTC 2023 : Method request headers: {}
Fri Jan 13 10:08:40 UTC 2023 : Method request body before transformations: {
    "dueDate": "2023-01-13T13:04:14.397Z"
}
Fri Jan 13 10:08:40 UTC 2023 : Endpoint request URI: https://states.eu-central-1.amazonaws.com/?Action=StartExecution
Fri Jan 13 10:08:40 UTC 2023 : Endpoint request headers: {Authorization=*****************************************************************************************************************************************************************************************************************************************************************************************270b51, X-Amz-Date=20230113T100840Z, x-amzn-apigateway-api-id=q4wi07nhcj, Accept=application/json, User-Agent=AmazonAPIGateway_q4wi07nhcj, X-Amz-Security-Token=IQoJb3JpZ2luX2VjEHoaDGV1LWNlbnRyYWwtMSJGMEQCIB7rsefFvEzfVHKXnxDHBrJbeAiABf+UzyOYW0qflCzr1USCNB3+rAF4b9lMFPi/Ir0SXmCruAgjT//////////8BEAMaDDMyNTQ1MzEyNTA1MiIMLWI1FLT3D/T/0ZSoKsICfQwQ+wURjQArtSA+UZmhRHZbhqScVfZ+X8uVBK/bkEDyj97aUZqIBr9rzDawkfq5LjnA4Si0aBrrLRcxnb2Xu7j3R4o9k2CRlaS7aAcgXMFmpVnVV/uDi5LXER777iRvBXIn2prwwvN3gdAx4H [TRUNCATED]
Fri Jan 13 10:08:40 UTC 2023 : Endpoint request body after transformations: 
{"input": "{\"dueDate\":\"2023-01-13T13:04:14.397Z\"}", "name": "e7fd711c-56f7-427e-8e58-87dbe5154193", "stateMachineArn":"arn:aws:states:eu-central-1:325453125052:stateMachine:services-scheduler"}
Fri Jan 13 10:08:40 UTC 2023 : Sending request to https://states.eu-central-1.amazonaws.com/?Action=StartExecution
Fri Jan 13 10:08:40 UTC 2023 : Received response. Status: 200, Integration latency: 91 ms
Fri Jan 13 10:08:40 UTC 2023 : Endpoint response headers: {x-amzn-RequestId=61be8d71-a46e-484e-8351-201c59584794, Date=Fri, 13 Jan 2023 10:08:40 GMT, Content-Type=application/x-amz-json-1.0, Content-Length=158}
Fri Jan 13 10:08:40 UTC 2023 : Endpoint response body before transformations: {"executionArn":"arn:aws:states:eu-central-1:325453125052:execution:services-scheduler:e7fd711c-56f7-427e-8e58-87dbe5154193","startDate":1.673604520313E9}
Fri Jan 13 10:08:40 UTC 2023 : Method response body after transformations: {"executionArn":"arn:aws:states:eu-central-1:325453125052:execution:services-scheduler:e7fd711c-56f7-427e-8e58-87dbe5154193","startDate":1.673604520313E9}
Fri Jan 13 10:08:40 UTC 2023 : Method response headers: {X-Amzn-Trace-Id=Root=1-63c12da8-453982ec322ab5856186ef8b, Access-Control-Allow-Origin=*, Content-Type=application/json}
Fri Jan 13 10:08:40 UTC 2023 : Successfully completed execution
Fri Jan 13 10:08:40 UTC 2023 : Method completed with status: 200

If I test the endpoint from outside (postman or curl) I get the following sequence of logs (I have enabled REST API logging in serverless config):

..............
Method request body before transformations: [Binary Data]
Execution failed due to configuration error: Unable to transform request
Method completed with status: 500

There is no setup for authorization or api keys and other endpoints from the same setup execute just fine.

Example request I'm trying with curl:

curl --location --request POST 'https://[API_ID].execute-api.eu-central-1.amazonaws.com/stage/schedule' \
--header 'Content-Type: application/json' \
--data-raw '{
    "dueDate": "2023-01-13T13:04:14.397Z"
}'

Additional Data

  • Serverless Framework Core Version you're using: 3.22.0
  • The Plugin Version you're using: 3.11.1
@motiejuss
Copy link
Author

For others experiencing similar issue, it's because in our serverless config we have apiGateway -> binaryMediaTypes: ['*/*'] which basically means all incoming payload is binary.

Is there a way to convert it to text using body mapping template like described here? https://www.serverless.com/plugins/serverless-step-functions#customizing-request-body-mapping-templates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant