PDF Generation fails on AWS Lambda using Python/Django

I have a strange issue, using the labstack python API, or python requests locally, pdf generation works just fine.

However when running inside a django app deployed using zappa to AWS lambda, i get 500 from labstack api.

Using labstack API, it raises keyError because code isn’t included in the response (not a json body)

Using requests with the following headers


{‘User-Agent’: ‘python-requests/2.23.0’, ‘Accept-Encoding’: ‘gzip, deflate’, ‘Accept’: ‘/’, ‘Connection’: ‘keep-alive’, ‘Authorization’: 'Bearer }

we get the following response:

{‘Date’: ‘Tue, 03 Mar 2020 15:53:15 GMT’, ‘Content-Type’: ‘application/json; charset=UTF-8’, ‘Content-Length’: ‘36’, ‘Connection’: ‘keep-alive’, ‘Set-Cookie’: ‘__cfduid=db33aeb22a4c2f30f29c7621645fb07d21583250795; expires=Thu, 02-Apr-20 15:53:15 GMT; path=/; domain=.labstack.com; HttpOnly; SameSite=Lax; Secure’, ‘access-control-allow-credentials’: ‘true’, ‘access-control-allow-origin’: ‘’, ‘vary’: ‘Origin’, ‘CF-Cache-Status’: ‘DYNAMIC’, ‘Expect-CT’: ‘max-age=604800, report-uri=“https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct”’, ‘Server’: ‘cloudflare’, ‘CF-RAY’: ‘56e4877f69fba66f-DUB’}

with the body

{‘message’: ‘Internal Server Error’}

It doesn’t matter url we request.

Any idea what we need to do?