每次我尝试部署函数时都会收到错误:
ERROR: gcloud crashed (TypeError): expected string or bytes-like object
我在 zip 文件中手动上传了相同的代码,没有任何问题。
这是命令:
gcloud functions deploy myfunction \
--runtime python39 \
--trigger-http \
--entry-point main \
--source . \
--region europe-west1 \
--project myproject \
--env-vars-file env.json
带有调试功能:
DEBUG: expected string or bytes-like object
Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 987, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 807, in Run
resources = command_instance.Run(args)
File "/usr/lib/google-cloud-sdk/lib/surface/functions/deploy.py", line 104, in Run
return command_v2.Run(args, self.ReleaseTrack())
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/command_lib/functions/v2/deploy/command.py", line 1065, in Run
_SetInvokerPermissions(args, function, is_new_function)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/command_lib/functions/v2/deploy/command.py", line 866, in _SetInvokerPermissions
service_ref_one_platform = resources.REGISTRY.ParseRelativeName(
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/resources.py", line 1082, in ParseRelativeName
return parser.ParseRelativeName(
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/resources.py", line 203, in ParseRelativeName
match = re.match(path_template, relative_name)
File "/usr/lib/google-cloud-sdk/platform/bundledpythonunix/lib/python3.9/re.py", line 191, in match
return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object
ERROR: gcloud crashed (TypeError): expected string or bytes-like object
根据您的评论,您似乎使用的是旧版本的
Google Cloud SDK 411.0.0
,这导致了以下错误消息:
错误:gcloud 崩溃(TypeError):需要字符串或类似字节的对象
我尝试按照最新版本的
Hello World
按照文档部署简单的
Gcloud CLI 468.0.0
功能,并且能够成功部署。
Google Cloud SDK 468.0.0
并重新部署。它应该按预期工作。