部署firebase云函数时创建函数项目失败

cwxwcias  于 2022-12-27  发布在  其他
关注(0)|答案(2)|浏览(147)

我正在尝试从本地计算机部署firebase函数
我运行下面的代码:

firebase deploy --only functions

我得到这个错误。

✔  functions: Finished running predeploy script.
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔  functions: required API cloudbuild.googleapis.com is enabled
✔  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (95.46 KB) for uploading
✔  functions: functions folder uploaded successfully
i  functions: creating Node.js 14 function messageNotification(us-central1)...
⚠  functions: failed to create function projects/xxx/locations/us-central1/functions/messageNotification

没有任何错误信息,只是说明函数创建失败。有人知道原因吗?提前感谢!

    • 编辑**

我按照约翰·汉利的建议跑了

firebase deploy --debug --only functions

并收到以下错误消息

[2021-08-05T01:49:33.605Z] <<< HTTP RESPONSE 400 {"vary":"X-Origin, Referer, Origin,Accept-Encoding","content-type":"application/json; charset=UTF-8","date":"Thu, 05 Aug 2021 01:49:33 GMT","server":"ESF","cache-control":"private","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
[2021-08-05T01:49:33.605Z] <<< HTTP RESPONSE BODY {"error":{"code":400,"message":"The request has errors","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"event_trigger","description":"Expected value channels/{channelId}/{messageId} to match regular expression [^/]+/[^/]+(/[^/]+/[^/]+)*"}]}]}}

我意识到我写函数的方式是错误的。我写它

export const messageNotification = functions.firestore
    .document("channels/{channelId}/{messageId}")...

但是我应该把它写成如下所示

export const messageNotification = functions.firestore
    .document("channels/{channelId}/messages/{messageId}")
plicqrtu

plicqrtu1#

要调试部署,请尝试两种方法:
添加命令行选项**--debug**”

firebase deploy --debug --only functions

检查日志中的消息:

firebase functions:log
gk7wooem

gk7wooem2#

请确保在定义文档触发器时使用正确的文档选择,格式为

.document("Collection/{documentID}/nestedCollection/{nestedDocumentId}")

相关问题