Firebase-tools: Deleting in non-interactive mode is not possible

Created on 17 Aug 2018  ·  18Comments  ·  Source: firebase/firebase-tools

Version info

"firebase-tools": "4.1.1"

Platform Information

OS X and Bitbucket Pipelines CI

Steps to reproduce

In Bitbucket pipelines CI, using non-interactive mode with env variables
firebase use myproject
firebase deploy with 5 functions in index.js

_In a later PR_
firebase deploy with just 4 functions in index.js

Expected behavior

  1. The full firebase deploy removes the "5th" function that is no longer in the latest index.js
  2. No manual steps/CLI commands are required (like in previous versions of firebase tools)

Actual behavior

Error: The following functions are found in your project but do not exist in your local source code:
... list of functions ...
Aborting because deletion cannot proceed in non-interactive mode. To fix, manually delete the functions by running:

Most helpful comment

Sure: We're constantly refactoring old functions and often replacing (swapping https onRequest for onCall for example). It's easier for us to delete the old function and add a new one. Sometimes we simply aren't using the function anymore, and want it gone.
We wouldn't delete a function every week, but now that it's not possible to do via CI, it means we have to add a manual step in review to manually delete before merging and auto deploying. It also means at least two developers need write access to our production functions, which we're trying to get away from for peace of mind.
If we had something like firebase deploy --allow-deletes and we maintain a good review process, our entire Dev team can freely create/update/delete anything without waiting on me to open up production CLI on my laptop while I'm working on something else.

I can understand why the default would be not to delete, but we're suprised it's not possible/blocked in non-interactive mode, assuming most people in that mode are thoroughly reviewing before deploying like we are?

All 18 comments

Hi, this is intentional behavior, since we got a lot of feedback that users did not like how the CLI automatically deleted their functions. So now we require user confirmation for deletions, which cannot be done in non-interactive.

This is why the release was a major version bump, to indicate a breaking change in behavior.

@laurenzlong could a flag be added to allow deletions in non-interactive mode? Deleting functions by hand in CLI for us is way less safe and inconvenient versus a good review/merge policy + CI deployments

Could you expand on your rationale a bit more? Are you deleting functions often during CI?

Sure: We're constantly refactoring old functions and often replacing (swapping https onRequest for onCall for example). It's easier for us to delete the old function and add a new one. Sometimes we simply aren't using the function anymore, and want it gone.
We wouldn't delete a function every week, but now that it's not possible to do via CI, it means we have to add a manual step in review to manually delete before merging and auto deploying. It also means at least two developers need write access to our production functions, which we're trying to get away from for peace of mind.
If we had something like firebase deploy --allow-deletes and we maintain a good review process, our entire Dev team can freely create/update/delete anything without waiting on me to open up production CLI on my laptop while I'm working on something else.

I can understand why the default would be not to delete, but we're suprised it's not possible/blocked in non-interactive mode, assuming most people in that mode are thoroughly reviewing before deploying like we are?

Thanks for the feedback Alan, I'll open up the discussion internally about this.

Thanks Lauren 🙌

We have exactly the same issue. It would help as a lot as well. We had to give up our automated deployments using Google Cloud Builder because of the update.

Not sure if anyone suggested it already.
Most of the users seem to prefer a flag where functions not present will get deleted.

This is not always the option everyone want's to have.
For example, we would like to have a flag, which allows us to just ignore these functions.
So the functions won't get an update or get deleted.

For example, if someone created a new function in a feature branch and deployed it using firebase deploy --only functions:functionName for testing purposes.
This won't affect any other function in production use.

And then someone tries to deploy a new version, then our CI pipeline would start and call the command
firebase deploy --ignore-missing-functions, then the deploy would update all present functions, create missing functions, but would not update or delete the function functionName.

I see the benefit of a flag to get back the old behaviour, so both behaviours would be great to have in my opinion.
Either delete missing functions or just ignore them.

Same here. Because we have lots of triggers and often times we need to move user database from prod to dev project for investigation and troubleshooting we need a way to disable all the triggers during json import.
And the only way to disable triggers we came up is to actually delete all the functions in dev project before the import - literally comment out all the index.js, deploy it to dev, then import the json and then revert all the functions back for further investigation of any reported issues.

If there is a way to disable triggers in a more friendly way with the updated CLI I would much appreciate any input on how to achieve that. Otherwise removing functions from CLI in a batch is still something we rely on.

@laurenzlong is this being addressed?

We will be adding an option to force deletes of missing functions soon.
We've heard the feedback, hopefully this helps. The default behavior will
remain the same.

On Fri, Oct 12, 2018, 5:06 AM Solomon Engel <[email protected] wrote:

@laurenzlong https://github.com/laurenzlong is this being addressed?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebase-tools/issues/877#issuecomment-429303503,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAD_npvEeL-UEG_Q5YNtNylQCi_9hKKks5ukIWtgaJpZM4WCBfg
.

@mbleigh Is there any option to not delete any function when I run firebase deploy?

For example, if I have 2 separate repositories with totally different functions which all deploy to the same Functions project.

So e.g.:
I have repos

  • "frontend", with the function:

    • languageRedirector

  • "backend", with:

    • onUserAuthenticated

Now if I run firebase deploy from the "frontend" repo I want to update only languageRedirector
and if I run firebase deploy from the "backend" repo I want to update only onUserAuthenticated

Is this possible?

@IchordeDionysos that is not possible, as far as I'm aware. During the deploy process, the functions are inspected to figure out what needs to be removed and what needs to be added. If one is "missing" from the code, the CLI will attempt to delete it.

Is this #999 something you are considering? :)
We really need this option as our CI script currently won't work without this...

I just put a note on that PR. While it's a good idea, there's a bit more internal process that has to happen to add a flag like this. I wouldn't expect something to happen in a number of days, but know that it's on our radar.

@IchordeDionysos In the meantime, is it possible for you to use --only functions:[function] on firebase deploy to get your CI working? You can find more details here: https://firebase.google.com/docs/cli/#deploy_specific_functions

For us the issue is resolved. We're able to deploy via Google Cloud Builder again.

Here's the "hack" that we are using to only upsert function (not delete others):

echo "n\n" | firebase deploy --only functions --interactive --token $FIREBASE_TOKEN

Would also appreciate having and explicit option such as --no-delete rather than relying on the question never changing 😏

Was this page helpful?
0 / 5 - 0 ratings