I've got an HTTP Cloud Function (Python 3.7) invoked by a Github webhook, and it usually (but not always) exits with a connection error when the event type is not a pull request. It always exits cleanly when it doesn't go inside the if block.
Here's the function:
def my_func(request):
event = request.headers.get("X-GitHub-Event", "unknown")
if event != "pull_request":
print("This is not a pull request")
return "This is not a pull request", 200
return "OK", 200
In the logs it shows up as:
"This is not a pull request"
"Function execution took 11 ms, finished with status: 'connection error'"
And on the Github side the response is an HTTP/500 error with the message "Error: could not handle the request".
I've redeployed it as a new function in a different project and the same thing happens. Sometimes one function will return 200 and the other returns 500 for the same event. Any idea what's happening here? Thanks :)