Skip to content

HttpApi lambda error mismatch with sam local #2590

Closed

Description

@iRoachie

Description:

Hey team,

Found a discrepancy between sam local start-api and running in an AWS account.

While running in an AWS account, unhandled errors thrown from AWS lambda connected with API gateway return a 500 internal server error.

While running locally via sam local start-api these same errors return a 200:

{
    "errorType": "Error",
    "errorMessage": "",
    "trace": [
        "Error",
        "    at Runtime.exports.index [as handler] (/var/task/app.js:13:9)",
        "    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
    ]
}

Steps to reproduce:

I've provided a repo https://github.com/iRoachie/http-api-example.

  • Clone the repo
For local:
  • sam local start-api
  • curl -i localhost:3000
HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 192
Server: Werkzeug/1.0.1 Python/3.8.7
Date: Fri, 05 Feb 2021 16:23:11 GMT

{"errorType": "Error", "errorMessage": "", "trace": ["Error", "    at Runtime.exports.index [as handler] (/var/task/app.js:13:9)", "    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"]}%
For AWS
  • sam deploy --guided
  • See outputs ApiURL
  • curl -i {ApiURL}
HTTP/2 500 
date: Fri, 05 Feb 2021 16:34:30 GMT
content-type: application/json
content-length: 35
apigw-requestid: aR7_khtxoAMEVlQ=

{"message":"Internal Server Error"}%    

Expected result:

sam local start-api should have the same output as running on AWS

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: mac os 10.15.7
  2. sam --version: 1.17.0
  3. AWS region: us-east-1

Activity

  1. ssenchenko commented on Dec 13, 2021

    @ssenchenko

    The team is aware of the request. We do not have an update to share at this time. However, we do tag PRs with issues they solve. Once the team prioritizes and solves it, you will be able to see that link in the issue

  2. added and removed
    stage/bug-reproThe issue/bug needs to be reproduced
    on Mar 17, 2023
  3. vicheey commented on Nov 13, 2026

    @vicheey
    Contributor

    Thanks for the report. Since v1.97.0 (#5749), local HttpApi function errors return 500, as they do in the cloud. Closing as fixed.

  4. github-actions commented on Nov 13, 2026

    @github-actions
    Contributor

    ⚠️COMMENT VISIBILITY WARNING⚠️

    Comments on closed issues are hard for our team to see.
    If you need more assistance, please either tag a team member or open a new issue that references this one.
    If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions