-
Notifications
You must be signed in to change notification settings - Fork 21
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
Connexion 3 issue with FlaskApp and WSGIResponder.wsgi #56
Comments
Can you provide a method for reproduction? |
test-api-68d50d1e-db07-4e24-952a-437efdc51d53.zip This is what I've uploaded to AWS Lambda It's pretty-much the connexion 3 tutorial |
And here is the "fixed" version without that line It returns me a base64 encoded response; which works with API Gateway The only other thing I can think of is that .venv/lib/python3.11/site-packages/asgi_aws/services/aws.py: async def receive(self) -> Message:
event = self.request["event"]
body = event.get("body", "")
if body is None:
body = b""
elif event.get("isBase64Encoded", False):
body = b64decode(body)
else:
body = body.encode()
return {
"type": "http.request",
"body": body,
"more_body": False,
}
@property
def response(self) -> Response:
event = self.request["event"]
if "version" in event:
is_base64_encoded = True
body = b64encode(self.body).decode()
else:
is_base64_encoded = False
try:
body = self.body.decode()
except UnicodeDecodeError:
is_base64_encoded = True
body = b64encode(self.body).decode()
return {
"statusCode": self.status_code,
"headers": dict(self.headers),
"body": body,
"isBase64Encoded": is_base64_encoded,
} |
Closing as this is actually an issue with asgi-aws and it's naive implementation. The hack should hold for Flask apps, but not any true ASGI. Solved using https://github.com/jordaneremieff/mangum, which "just-works" ™️ and should work with any True ASGI app, due to a more robust way of handling |
.venv/lib/python3.11/site-packages/a2wsgi/wsgi.py
Always leads to AWS returning
""
as the body.I'm fairly certain it's this piece of code as body is a Bytes object
chunk = b"Hello lewis"
version affected
1.10.4
(ships as transitive dependency via Connexion 3)The text was updated successfully, but these errors were encountered: