Serverless endpoint not responding if query handler returns False

23 views Asked by At

I've been having some problems understanding the root cause of my GraphQL endpoint not responding.

I am using serverless-offline, and I am calling a handler function writen in Python, which returns a boolean.

The main symptom is this:

  • If my handler returns True, happy days, no problem :)
  • If my handler returns False, the endpoint just doesn't respond (i.e. it keeps waiting for a response that never comes).

Here are the traces of my postman call when the handler returns True.

POST /2015-03-31/functions/FOO/invocations HTTP/1.1
x-api-key: **SECRET_KEY**
Content-Type: application/json
User-Agent: PostmanRuntime/7.37.0
Accept: */*
Postman-Token: **POSTMAN_TOKEN**
Host: localhost:5002
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 115
 
{
"fieldName": "MyEndpoint",
"arguments": {
"containAttrs": {"name": ["Helicopter"]}
}
}
 
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
vary: origin
access-control-allow-credentials: true
access-control-expose-headers: WWW-Authenticate,Server-Authorization
cache-control: no-cache
content-length: 4
Date: Fri, 15 Mar 2024 18:57:02 GMT
Connection: keep-alive
Keep-Alive: timeout=5
 
true

Unfortunately, I can't put the traces of when the handler returns False, because there aren't any.

I've followed the code (including serverless-offline). I pinpointed that the reason why it's not executing is on this file:

https://github.com/dherault/serverless-offline/blob/v7.0.0/src/lambda/handler-runner/python-runner/PythonRunner.js

In line 142, we read the value of "parsed", and in lines 144-147, we prepare the response only if "parsed" exists. My issue is that "parsed" is False (because of my function handler) and then it jumps to line 150.

serverless-offline PythonRunner

I am not convinced that this is a problem in serverless-offline since it should be very common to return a "False" statement in handler, which make me believe that I am missing something, I am just not sure what.

Any help would be appreciated.

0

There are 0 answers