部署时,firebase函数INVALID_ARGUMENT HTTP错误400

时间:2019-05-14 08:47:58

标签: firebase-realtime-database google-cloud-functions

现在尝试在“ firebase部署”中使用Firebase实时数据库功能解决问题5个小时:

直到今天都没有这个

功能是:

exports.makeUppercase = functions.database.ref('/userfollowers/{pushId}/followers')
    .onWrite((change, context) => {
      // Only edit data when it is first created.
      if (change.before.exists()) {
        return null;
      }
      // Exit when the data is deleted.
      if (!change.after.exists()) {
        return null;
      }
      // Grab the current value of what was written to the Realtime Database.
      const original = change.after.val();
      console.log('Uppercasing', context.params.pushId, original);
      const uppercase = original.toUpperCase();
      // You must return a Promise when performing asynchronous tasks inside a Functions such as
      // writing to the Firebase Realtime Database.
      // Setting an "uppercase" sibling in the Realtime Database returns a Promise.
      return change.after.ref.parent.child('uppercase').set(uppercase);
    });
which is straight out of documentation.

终端显示:

⚠  functions: failed to create function makeUppercase
HTTP Error: 400, The request has errors

云功能日志显示:

{“ @ type”:“ type.googleapis.com/google.cloud.audit.AuditLog”,“状态”:{“代码”:3,“消息”:“ INVALID_ARGUMENT”},“ authenticationInfo”:{ “ principalEmail”:“ nicoaratalpes@gmail.com”},“ requestMetadata”:{“ callerIp”:“ 86.120.235.246”,“ callerSuppliedUserAgent”:“ FirebaseCLI / 3.19.0,gzip(gfe),gzip(gfe)”, “ requestAttributes”:{“ time”:“ 2019-05-14T08:34:18.563Z”,“ auth”:{}},“ destinationAttributes”:{}},“ serviceName”:“ cloudfunctions.googleapis.com”, “ methodName”:“ google.cloud.functions.v1.CloudFunctionsService.CreateFunction”,“ authorizationInfo”:[{“ resource”:“ projects / parkour-9136c / locations / us-central1 / functions / makeUppercase”,“ permission”: “ cloudclouds.functions.create”,“ granted”:true,“ resourceAttributes”:{}},{“ permission”:“ cloudfunctions.functions.create”,“ granted”:true,“ resourceAttributes”:{}}] “ resourceName”:“项目/ parkour-9136c / locations / us-central1 / functions / makeUppercase”,“ request”:{“ location”:“项目/ parkour-9136c / locations / us-central1”,“ @ type”: “ type.googleapis.com/google.cloud.functions.v1.C reateFunctionRequest“,” function“:{” labels“:{” deployment-tool“:” cli-firebase“},” entryPoint“:” makeUppercase“,” eventTrigger“:{” eventType“:” providers / google.firebase。 database / eventTypes / ref.write“,”资源“:”项目/_/instances/parkour-9136c/refs/userfollowers/{pushId}/followers","service":"firebaseio.com"},"sourceUploadUrl“: “ https://storage.googleapis.com/gcf-upload-us-central1-f5adb7fe-7321-4f3c-8fe0-2b2307d26138/5b099ea8-161b-44a7-a3bd-18ce75c64859.zip?GoogleAccessId=service-807137615499@gcf-admin-robot.iam.gserviceaccount.com&Expires=1557824657&Signature=PJKzJsZtHWO1kIkmrSojpdgvb0jRzV91eNC9rZc4j%2FMcoHjILGm36FKCt6qQ2fxeAUu1%2FbrxpagdI7fHmUUUrDdTmnTNISr7FiN61sifUI%2B%2FGnUwo8SguzvrA7kADFqu8nD05FAo7BvG7biUrHmLgISlwo5dTKqcTSmExnaICA1tHYxjz%2Fk0RbmdGkcQ5HdeCKBnW0R7wQPsxswQyvR4cAU4WD2m3PPM9lncVr7pB%2Fh77FboGLi3sq%2FGHyEwUtjfUmyN9d%2FYUpKs48TMsGPknAGIvaFFUWQR23YCDUcrPipq1nW2W1JUdf5nGylYmVEeyF3jLrm%2BsOIcXiZ6LCRhpg%3D%3D”,“名称”:“ projects / parkour-9136c / locations / us-central1 / functions / makeUppercase”}}}

解决方案是什么? 谢谢

https://github.com/firebase/firebase-tools/issues/1317

2 个答案:

答案 0 :(得分:0)

更新:解决方案是将firebase-tools更新到6.10,我安装了3.19。

答案 1 :(得分:0)

在内部使用这些命令更新Firebase CLI和SDK Firebase项目的功能文件夹

npm install firebase-functions@latest firebase-admin@latest --save
npm install -g firebase-tools