openwhisk error: "The action did not return a dictionary."

openwhisk error: "The action did not return a dictionary."

尝试调用 openwhisk 操作时,出现 400 错误,结果和日志如下:

结果:

114492bd33e444c88492bd33e4a4c8a8
{
  "error": "The action did not return a dictionary."
}

日志

[
"2018-02-12T20:20:27.224409701Z stderr: Traceback (most recent call 
last):",
"2018-02-12T20:20:27.224534535Z stderr: File \"pythonrunner.py\", line 
88, in run",
"2018-02-12T20:20:27.224550304Z stderr: exec('fun = %s(param)' % 
self.mainFn, self.global_context)",
"2018-02-12T20:20:27.224559746Z stderr: File \"<string>\", line 1, in 
<module>",
"2018-02-12T20:20:27.224578509Z stderr: File \"__main__.py\", line 308, 
in main",
"2018-02-12T20:20:27.224587541Z stderr: if 
datos_usuario[\"__ow_method\"] 
== \"get\":",
"2018-02-12T20:20:27.224596543Z stderr: KeyError: '__ow_method'"
]

到目前为止该操作一直正常运行,这让我认为该错误可能与访问 API 的特定问题有关。关于如何解决这个问题有什么想法吗?

谢谢!

您需要将该操作创建为 webaction。该错误提示 __ow_method 不存在,只有当您的操作是网络操作时才会存在。

您的操作对该字段有任何作用吗?如果你想有条件地编写你的动作(如:检测它是否实际上是一个网络动作)你需要检查该字段是否实际存在。在 python 中,您将使用 get() 获取密钥或 None.

就没有 returning 任何有意义的事情而言:似乎你的操作随机崩溃而没有对那个错误做任何事情。可能会更新运行时本身以捕获任何未捕获的错误和 return 更有意义的东西。在这种情况下,可能需要针对存储库提出问题。