lambda-proxy
lambda-proxy copied to clipboard
"Missing or invalid path" for HTTP $default integration
When using the $default integration in an HTTP API, all requests result in a "Missing or invalid path" error.
The code in the Lambda function:
from lambda_proxy.proxy import API
lambda_handler = API(name="app", debug=True)
@lambda_handler.route('/test/tests/<id>', methods=['GET'], cors=True)
def print_id(id):
return ('OK', 'plain/text', id)
The log produced:
[app] - [DEBUG] -
{
"version": "2.0",
"routeKey": "$default",
"rawPath": "/test/tests/001",
"rawQueryString": "",
"headers": {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"authorization": "Basic Y3JsOmdpdmVtZWxvZ3NwbGVhc2U=",
"cache-control": "no-cache",
"content-length": "0",
"host": "45fyv6th2h.execute-api.us-east-1.amazonaws.com",
"postman-token": "6d6f0cb8-b9f4-46a8-a2db-8cc92ecff7df",
"user-agent": "PostmanRuntime/7.26.8",
"x-amzn-trace-id": "Root=1-5fdce9cd-48c25cf12f205f0c4abfe699",
"x-forwarded-for": "67.252.44.81",
"x-forwarded-port": "443",
"x-forwarded-proto": "https"
},
"requestContext": {
"accountId": "214149537144",
"apiId": "45fyv6th2h",
"domainName": "45fyv6th2h.execute-api.us-east-1.amazonaws.com",
"domainPrefix": "45fyv6th2h",
"http": {
"method": "GET",
"path": "/test/tests/001",
"protocol": "HTTP/1.1",
"sourceIp": "67.252.44.81",
"userAgent": "PostmanRuntime/7.26.8"
},
"requestId": "Xwl4LiVEIAMEPig=",
"routeKey": "$default",
"stage": "$default",
"time": "18/Dec/2020:17:41:33 +0000",
"timeEpoch": 1608313293816
},
"isBase64Encoded": false
}
Presumably the error is occurring here. This implies that self.path gets set to None here, which would make sense given that this function isn't going to find what it's looking for in that event.
I've messed around with all sorts of configurations, but to no avail. I'm not doing anything special, but it's possible that I've configured something incorrectly. In any case, I can't seem to get this to work at all.