当前位置: 首页 > 知识库问答 >
问题:

firebase函数在部署时出现无效的_参数HTTP错误400

焦博实
2023-03-14

现在尝试解决Firebase实时数据库功能上的问题5个小时,请访问“Firebase部署”:

直到今天才有这个

功能是:

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"、"状态":{"code": 3、"消息":"INVALID_ARGUMENT"}、"验证信息":{"主体电子邮件":"nicoaratalpes@gmail.com"}、"请求元数据":{"调用者Ip":"86.120.235.246"、"调用者支持用户代理":"Firebase CLI/3.19.0, gzip(gfe), gzip(gfe)","请求属性":{"时间":"2019-05-14T08:34:18.563Z","授权":{}},"目的地属性":{}},"服务名称":"cloudfunctions.googleapis.com","方法名称":"google.cloud.functions.v1。云服务。CreateFunction","AuthizationInfo":[{"资源":"项目/跑酷-9136c/位置/us-中心1/函数/makeUppercase","权限":"cloudfunctions.functions.create","授予": true,"resourceAtinites":{}},{"权限":"cloudfunctions.functions.create","授予": true,"resourceAtinites":{}}],"resourceName":"项目/跑酷-9136c/位置/us-Centural1/函数/makeUppercase","请求":{"位置":"项目/跑酷-9136c/位置/us-Centural1","@type":"type.googleapis.com/google.cloud.functions.v1.CreateFunctionRequest","函数":{"标签":{"部署工具":"cli-Firebase"},"entryPoint":"makeUppercase","eventTrigger":{"eventType":"提供者/google.firebase.database/eventTypes/ref.write,"资源":"项目/_ /instances/parkour-9136c/refs/userfollowers/{pushId}/关注者","服务":"firebaseio.com"},"Source ceUploadUrl":"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

解决方案是什么?谢谢

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

共有2个答案

徐星阑
2023-03-14

在Firebase项目的functions文件夹中使用以下命令更新Firebase CLI和SDK:

npm install firebase-functions@latest firebase-admin@latest --save
npm install -g firebase-tools
苏培
2023-03-14

更新:解决方案是将Firebase工具更新到6.10,我有3.19。

 类似资料:
  • 我已经设置和快速服务器上运行Firebase云功能。现在,我试图使用CLI使用“Firebase部署-仅函数”将其部署到Firebase,但每次都失败,说有一个意外的令牌。我怀疑在index.js文件中使用异步箭头函数有问题,但我不确定,我也需要它们来完成我的项目。 这是索引。js文件: 以下是我在尝试运行firebase deploy(仅限函数)时遇到的错误: ==部署到“homunculus-

  • 我已经使用firebase云函数一段时间了,今天在代码中修复了一个小错误,在尝试部署时出现了以下错误。我取消了该更改,并尝试使用上次提交的稳定更改再次部署,但仍然是相同的错误。有什么解决办法吗?PS:这是一个typescript项目,我用tsc编译它。

  • 我在过去多次部署Firebase功能。由于某些原因,最近(大约2-3天)我经常在部署时出错。我使用windows来释放代码。当我尝试在我的Linux系统和Mac系统中设置相同的项目时,部署工作正常。从Windows环境发布可能存在的问题。 以下是部署时遇到的问题。 ! 功能[付款(us-central1)]:部署错误。加载用户代码时函数失败。这可能是由于用户代码中的错误造成的。错误消息:错误:请检

  • 错误:分析函数触发器时出错。 /private/var/folders/s3/gnf3bs6s0_n5jx27n2zj3xwr0000gn/T/fbfn_75373XQetWUjR4EdN/index.js:21});^ 对象的createScript(vm.js:74:10)上的参数列表后的语法错误(缺少)。在模块上运行InthisContext(vm.js:116:10)_在对象处编译(mod

  • 每当我运行“Firebase部署-只有函数”时,它就会出现这个错误分析函数触发器时出错。 类型错误:函数。https。onCall(…)。那么它就不是对象的函数了。(C:\Users\Lenovo\Desktop\Firebase Revision\functions\index.js:11:4)在模块中_在对象处编译(internal/modules/cjs/loader.js:1158:30)

  • TypeError:无法读取属性'val'在exports.onDataAdded.functions.database.ref.onCreate.event(/user_code/index.js: 5:28)在Object.(/user_code/node_modules/fire base-函数/lib/cloud-functions.js:112: 27)在下一个(本机)在 /user_c