Skip to content

API Gateway HTTP API Support - The incoming event is not a valid request from Amazon API Gateway or an Application Load Balancer #329

@electricsam

Description

@electricsam
  • Framework version: 1.4
  • Implementations: Spring Boot

Scenario

I set up an API Gateway of type HTTP API and made a request to it. I get a 500 response returned and the following is in the logs:

com.amazonaws.serverless.exceptions.InvalidRequestEventException: The incoming event is not a valid request from Amazon API Gateway or an Application Load Balancer

It looks like a check is made for the httpMethod field, which is not present in the HTTP API request:

{
    "version": "2.0",
    "routeKey": "GET /ping",
    "rawPath": "/v1/ping",
    "rawQueryString": "",
    "headers": {
        "accept": "*/*",
        "accept-encoding": "gzip, deflate, br",
        "cache-control": "no-cache",
        "content-length": "0",
        "host": "9vj0lwq3c5.execute-api.us-west-2.amazonaws.com",
        "postman-token": "15dec34a-ce88-4de2-a228-11bf679a5358",
        "user-agent": "PostmanRuntime/7.22.0",
        "x-amzn-trace-id": "Root=1-5e710c20-d322154cbc19a7c04f8e6a54",
        "x-forwarded-for": "71.218.63.155",
        "x-forwarded-port": "443",
        "x-forwarded-proto": "https"
    },
    "requestContext": {
        "accountId": "529841721878",
        "apiId": "9vj0lwq3c5",
        "domainName": "9vj0lwq3c5.execute-api.us-west-2.amazonaws.com",
        "domainPrefix": "9vj0lwq3c5",
        "http": {
            "method": "GET",
            "path": "/v1/ping",
            "protocol": "HTTP/1.1",
            "sourceIp": "71.218.63.155",
            "userAgent": "PostmanRuntime/7.22.0"
        },
        "requestId": "Ji7VCiIpPHcEPNw=",
        "routeId": null,
        "routeKey": "GET /ping",
        "stage": "v1",
        "time": "17/Mar/2020:17:42:56 +0000",
        "timeEpoch": 1584466976114
    },
    "isBase64Encoded": true
}

Expected behavior

Framework handles requests for the HTTP API type of API Gateway

Actual behavior

Error is returned

Steps to reproduce

Set up an API Gateway of type HTTP API with a Lambda backend. Make a request.

Full log output

com.amazonaws.serverless.exceptions.InvalidRequestEventException: The incoming event is not a valid request from Amazon API Gateway or an Application Load Balancer

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions