【发布时间】:2020-05-11 00:49:11
【问题描述】:
我有一个由 Github webhook 调用的 HTTP 云函数 (Python 3.7),当事件类型不是拉取请求时,它通常(但不总是)以连接错误退出。当它没有进入 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。知道这里发生了什么吗?谢谢:)
【问题讨论】:
-
谢谢,我可以重现这个。现在看看。
-
您好,您为 webhook 配置了哪种内容类型?是
application/x-www-form-urlencoded还是application/json?如果您使用application/json,错误是否仍然存在? -
是应用程序/json
-
这似乎是 GCP 的间歇性内部问题,我们正在尝试找出根本原因。感谢您的耐心等待。
标签: python-3.x google-cloud-platform google-cloud-functions github-webhook