firebase-tools
firebase-tools copied to clipboard
`firebase deploy` fails to delete task function with an underscore in its name
[REQUIRED] Environment info
firebase-tools: 13.11.4
Platform: Ubuntu 23.10 / fish
[REQUIRED] Test case
from firebase_functions import tasks_fn
@tasks_fn.on_task_dispatched()
def dummy_function(request: tasks_fn.CallableRequest) -> str:
return "Hello World"
[REQUIRED] Steps to reproduce
- Initialize functions.
- Save the above function in
functions/main.py(the default). - Execute
firebase deploy --only functions.dummy_functionwill be deployed. (cf. https://github.com/firebase/firebase-tools/issues/6324) - Rename
dummy_functiontodummyinfunctions/main.py. - Execute
firebase deploy --only functions. When queried for deletion ofdummy_function, answery(yes).
[REQUIRED] Expected behavior
The old function should be deleted.
[REQUIRED] Actual behavior
The old function is not deleted. Instead, an error is shown.
✔ functions: functions folder uploaded successfully
The following functions are found in your project but do not exist in your local source code:
dummy_function(us-central1)
If you are renaming a function or changing its region, it is recommended that you create the new function first before deleting the old one to prevent event loss. For more info, visit https://firebase.google.com/docs/functions/manage-functions#modify
? Would you like to proceed with deletion? Selecting no will continue the rest of the deployments. (y/N)
i functions: deleting Python 3.12 (2nd Gen) function dummy_function(us-central1)...
HTTP Error: 400, Queue ID "dummy_function" can contain only letters ([A-Za-z]), numbers ([0-9]), or hyphens (-). Queue ID must be between 1 and 100 characters.
Hey @jangop, thanks for reaching out and providing a detailed report! I was able to reproduce the behavior you mentioned. Just to note, one thing I noticed is that during the first deployment, an error is also being raised, however the functions still seem to be deployed.
I’ll raise this to our engineering team so they can take a look.
I'm having trouble with the same error :(
same!
Hey @jangop, I'm unable to reproduce your issue by successfully deploying a task queue function with the name "dummy_function". Although 2nd gen functions do generally allow underscores in their names, we have additional restrictions on task queue function names specifically. This is because at deployment, the Firebase CLI will attempt to create a Cloud Task Queue with the same name as your function trigger, but Cloud Tasks does not allow underscores in queue names, so the deployment logic should fail. To be precise, the name of your Cloud Task Queue (and therefore, your task queue trigger) "can contain only letters ([A-Za-z]), numbers ([0-9]), or hyphens (-)" and "must be between 1 and 100 characters".
Could you try deploying a task queue function with an underscore in its name again, and let me know if it's still successfully deploying?
Hey @jangop, I'm unable to reproduce your issue by successfully deploying a task queue function with the name "dummy_function".
@blidd-google Which version of firebase-tools are you using?
Note the example I provided in the original post and that @aalej was indeed able to reproduce the reported behavior.
Is there a resolution available, I'm unable to delete/deploy new function due to this.
Is there a resolution available, I'm unable to delete/deploy new function due to this.
You should still be able to deploy new functions, simply by giving them new, unique names. This does, of course, mean that you will be littering your project with “dead” functions.
You can still manually delete functions (via console.cloud.google.com). This is cumbersome, but possible.
As implied by @blidd-google above, it should not longer be possible to create functions with underscores in their names. For many teams, this might not be acceptable, as it goes against established naming practices in Python.
Personally, I suggest you look around for an alternative framework.
I've just spend a few hours trying to get a project running with Task Queue, but nothing worked.
Finally I started creating a minimal issue-reproduce example, and noticed that things did work just fine with camelCase. Using underscore as the search-term, send me directly to this issue.
The details provided by @blidd-google makes total sense, but the error thrown while I fire up the emulator, is nothing more than very confusing:
⚠ Error adding Task Queue function: FirebaseError: Unable to parse JSON: SyntaxError: Unexpected token I in JSON at position 0
This error is thrown in a firebase env, where we use modules, and each function are exported as consts in the primary "functions/index.js" file.
As this issue seems to be about the same, I won't re-create another.
I see two ways of fixing this:
- Handle underscore better (All functions used in my project are in underscore styled, but I guess we can live with a camelCase-styled function. I guess we need to take a "rename" functions-day at some point in the future)
- Better error thrown, if the user does use underscore-styles (snake_case, in my case)
I'm commenting here, to help other people finding the issue by searching for similar thrown errors.