我有一个HTTP云函数(Python 3.7),由Github webhook调用,当事件类型不是pull request时,它通常(但不总是)会出现连接错误,而当它不进入if块时,它总是干净地退出。
这里是函数:
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
在日志中它显示为:
"This is not a pull request"
"Function execution took 11 ms, finished with status: 'connection error'"
在 Github 方面的响应是 HTTP/500 错误,消息为“错误:无法处理请求”。
我已经将其重新部署为不同项目中的新函数,但仍然出现相同的情况。有时一个函数会返回200,而另一个函数对于相同的事件则返回500. 你有任何想法这里发生了什么吗?谢谢 :)
application/x-www-form-urlencoded
还是application/json
?如果使用application/json
,错误是否仍然存在? - Dustin Ingram