Firebase Cloud Function 在创建时触发,但引发“资源字符串与预期格式不匹配”错误

问题描述 投票:0回答:0

我正在使用 Google-Github-Actions 部署 Firebase Cloud Function。

  - id: onItemCreate
    name: Deploy onItemCreate
    uses: google-github-actions/[email protected]
    with:
      name: "onItemCreate"
      entry_point: "onItemCreate"
      runtime: ${{ env.RUNTIME }}
      region: ${{ env.GCP_REGION }}
      build_service_account: ${{ env.SERVICE_ACCOUNT_BUILD }}
      service_account: ${{ env.SERVICE_ACCOUNT_RUN }}
      event_trigger_type: "providers/cloud.firestore/eventTypes/document.create"
      event_trigger_resource: "projects/my-project-id/databases/my-firestore-name/documents/items/{itemId}"
      event_trigger_service_account: ${{ env.SERVICE_ACCOUNT_RUN }}

每当在

/items
中创建文档时,云功能都会正确触发。但总是引发同样的错误。示例:我在
/items
中创建一个文档(id:sfgQxqkDAcGXePoKcTQB)并收到以下错误:

onItemCreatezd7hse2sjkl2 Error: Resource string did not match expected format: projects/my-project-id/databases/my-firestore-name/documents/items/sfgQxqkDAcGXePoKcTQB.
    at splitResource (/workspace/node_modules/@google-cloud/functions-framework/build/src/middleware/background_event_to_cloud_event.js:104:19)
    at backgroundEventToCloudEventMiddleware (/workspace/node_modules/@google-cloud/functions-framework/build/src/middleware/background_event_to_cloud_event.js:131:72)
    at Layer.handle [as handle_request] (/workspace/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/workspace/node_modules/express/lib/router/index.js:328:13)
    at /workspace/node_modules/express/lib/router/index.js:286:9
    at Function.process_params (/workspace/node_modules/express/lib/router/index.js:346:12)
    at next (/workspace/node_modules/express/lib/router/index.js:280:10)
    at legacyPubSubEventMiddleware (/workspace/node_modules/@google-cloud/functions-framework/build/src/pubsub_middleware.js:72:5)
    at Layer.handle [as handle_request] (/workspace/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/workspace/node_modules/express/lib/router/index.js:328:13) 

我不知道如何调试它,因为云函数甚至无法运行,因为这个错误是在调用之前引发的。我也很困惑,因为资源确实符合预期的格式,如果不符合,那么为什么会触发该函数?

firebase google-cloud-platform google-cloud-firestore google-cloud-functions github-actions
© www.soinside.com 2019 - 2024. All rights reserved.