2
votes

I'm having some major issues with my firebase functions. I'm trying to create an https request so that I can send data to Firebase.

I have a super simple code just to test, and it's causing errors:

Here is my code (there should be no problem with this code):

exports.fetchPosts = functions.https.onRequest((req, res) => {
    console.log(req)
    res.send("Hello!")
})

my index.ts file is 700 lines long.. without fetchPosts it deploys perfectly fine.. with fetchPosts I get these errors..

Here is the error:

! functions: failed to create function fetchPosts

HTTP Error: 400, The request has errors

and here is the verbose error message:

[2019-06-22T16:09:13.362Z] <<< HTTP RESPONSE 400 vary=X-Origin, Referer, Origin,Accept-Encoding, content-type=application/json; charset=UTF-8, date=Sat, 22 Jun 2019 16:09:11 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="46,44,43,39", accept-ranges=none, connection=close [2019-06-22T16:09:13.362Z] <<< HTTP RESPONSE BODY code=400, message=The request has errors, status=INVALID_ARGUMENT, details=[@type=type.googleapis.com/google.rpc.BadRequest, fieldViolations=[field=runtime, description=Runtime field cannot be empty.]] ! functions: failed to create function fetchPosts HTTP Error: 400, The request has errors

Any ideas what the issue might be? This seems ridiculous, as the code literally should work.

1
The error is saying there's a problem with the request. How exactly are you making the request?Doug Stevenson
@DougStevenson I'm not sure I understand what you mean by how I'm making the request... It's a function in my Functions file and I'm trying to deploy it via: firebase deploy --only functions, but it's producing that error. If I remove the fetchPosts function from the code it deploys perfectly fineSimon
If you're having problems with deployment that don't have actionable messages you can follow, you should contact Firebase support directly. support.google.com/firebase/contact/supportDoug Stevenson
The error message is telling you that you have not specified the runtime. What is your deploy command?John Hanley
You have no other files that are part of your deployment. You are leaving something out which is the answer to your problem.John Hanley

1 Answers

0
votes

Managed to fix this issue after weeks!! What finally worked for me:

  • npm i -g firebase-tools@latest
  • Deleted package-lock.json file
  • Deleted node_modules folder
  • npm install
  • firebase deploy

Hope that can help someone in the same position!!