API Gateway call results in [ERROR] KeyError: 'path'
Closed this issue · 3 comments
Python Version
3.8
Package Version
2.12.1
Description
I'm trying to call this really simple app with API Gateway (REST) Lambda integration:
#!/usr/bin/python3
import urllib3
from flask import Flask
from apig_wsgi import make_lambda_handler
app = Flask(__name__)
lambda_handler = make_lambda_handler(app)
@app.route('/eventprint', methods=['GET'])
def print_event():
return {"status": 200, "message": "OK"}
if __name__ == "__main__":
app.run(debug=True)
but I got the following error:
[ERROR] KeyError: 'path'
Traceback (most recent call last):
File "/var/lang/lib/python3.8/site-packages/apig_wsgi.py", line 45, in handler
environ = get_environ_v1(
File "/var/lang/lib/python3.8/site-packages/apig_wsgi.py", line 73, in get_environ_v1
"PATH_INFO": urllib.parse.unquote(event["path"], encoding="iso-8859-1"),
The application works with ALB.
Has anybody run into this issue before? What am I doing wrong?
Can you compare your deployment setup with the example app?
apig-wsgi/example/deployment/files/cloudformation_site.yml
Lines 135 to 180 in 8ce41e4
For whatever reason your ALB seems not to be sending path. Perhaps there's a change in config that causes that.
Hi Adam,
Thank you for the quick response. The app works with ALB.
The problem happens when I call it from API Gateway.
OK, I looked into the API Gateway integration example.
I made it work with +proxy resource. Thanks again!