firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Improve error messaging around function dot-notation deploys

Open desduvauchelle opened this issue 6 years ago • 8 comments

Environment info

firebase-tools: 8.1.1 Platform: MacOs

Test case

$ firebase deploy --only functions:trig-users-onUserUpdate

Steps to reproduce

  1. Have a project setup
  2. Create a cloud function
  3. Try to deploy just that function, ex:
$ firebase deploy --only functions:trig-users-onUserUpdate

Expected behavior

...
✔  functions[trig-users-onUserUpdate(us-central1)]: Successful update operation.
...

Function deployed.

Actual behavior

i  functions: current functions in project: trig-auth-createAuthUser(us-central1), trig-auth-onDeleteUser(us-central1), trig-users-onUserUpdate(us-central1)
⚠  functions: the following filters were specified but do not match any functions in the project: trig-users-onUserUpdate

Function wasn't deployed

desduvauchelle avatar Apr 24 '20 14:04 desduvauchelle

What does your index.js look like?

You might want:

--only trig.users.onUserUpdate

On Fri, Apr 24, 2020, 7:23 AM Denis Duvauchelle [email protected] wrote:

[REQUIRED] Environment info

firebase-tools: 8.1.1 Platform: MacOs [REQUIRED] Test case

$ firebase deploy --only functions:trig-users-onUserUpdate

[REQUIRED] Steps to reproduce

  1. Have a project setup
  2. Create a cloud function
  3. Try to deploy just that function, ex:

$ firebase deploy --only functions:trig-users-onUserUpdate

[REQUIRED] Expected behavior

...

✔ functions[trig-users-onUserUpdate(us-central1)]: Successful update operation.

...

Function deployed. [REQUIRED] Actual behavior

i functions: current functions in project: trig-auth-createAuthUser(us-central1), trig-auth-onDeleteUser(us-central1), trig-users-onUserUpdate(us-central1)

⚠ functions: the following filters were specified but do not match any functions in the project: trig-users-onUserUpdate

Function wasn't deployed

— 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/2166, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAH7VYJE32KSQUX2J7RQTROGOHDANCNFSM4MQERDMQ .

mbleigh avatar Apr 24 '20 14:04 mbleigh

index.js

const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp()

const users = require('./triggers/users')
const posts = require('./triggers/posts')
const auth = require('./triggers/auth')
const comments = require('./triggers/comments')
const likes = require('./triggers/likes')
const following = require('./triggers/following')
const triggers = {
	users,
	posts,
	auth,
	comments,
	likes,
	following
}

exports.trig = triggers

const timelines = require('./queries/timelines')

const queries = {
	timelines
}
exports.queries = queries

desduvauchelle avatar Apr 24 '20 14:04 desduvauchelle

The issue is that, for some reason, the deploy --only filter expects you to use dot notation to separate the modules / directories.

If you try this, it will work:

$ firebase deploy --only functions:trig.users.onUserUpdate

i.e. change the - for .

I believe this is very counter intuitive, but it is what it is for now.

¯_(ツ)_/¯

MichaelGradek avatar Apr 24 '20 15:04 MichaelGradek

In agreement about the confusion. But works! Thanks.

I don't know if the firebase team want to pursue this further or not, I'll leave it open for them to decide.

desduvauchelle avatar Apr 24 '20 16:04 desduvauchelle

We use dot notation because we allow for exporting groups of functions and deploying them together, for instance:

exports.myGroup = {fn1: functions.https.onRequest(), fn2: functions.https.onRequest()}

Where I can now deploy both functions with:

firebase deploy --only functions:myGroup
# or
firebase deploy --only functions:myGroup.fn1

Function names cannot have periods in them, but the hierarchy makes dot-notation make more sense than dash notation.

I think the action here is probably to have a better error message before deploy if you include dashes (which are not allowed by our trigger parser), so I'll leave it open and edit the title to reflect.

mbleigh avatar Apr 24 '20 16:04 mbleigh

It's a good reason to use dot, didn't know it was possible. In my case, I don't have any dashes in my names. They were added by the cli.

Example of what I had

// ---- triggers/user.js
exports.onUserUpdate = ....

// index.js
const users = require('./triggers/users')
const triggers = {
    users
}
exports.trig = triggers

So the solution for my issue is not be displaying errors for using - (but that might be useful if someone did), but instead list the function names with . in the console...example:

1)
// FROM
 i  functions: updating Node.js 10 function trig-auth-createAuthUser(us-central1)..
// TO
i  functions: updating Node.js 10 function trig.auth.createAuthUser(us-central1)..

2) 
// FROM
✔  functions[trig-auth-onDeleteUser(us-central1)]: Successful update operation. 
// TO
✔  functions[trig.auth.onDeleteUser(us-central1)]: Successful update operation.

3)
// FROM
i  functions: current functions in project: trig-auth-createAuthUser(us-central1), trig-auth-onDeleteUser(us-central1)
// TO
i  functions: current functions in project: trig.auth.createAuthUser(us-central1), trig.auth.onDeleteUser(us-central1)
 

desduvauchelle avatar Apr 24 '20 16:04 desduvauchelle

For me dashes do not work at all. So when deploying the CLI lists all functions using dash-notation but when you want to provide a function name as an input argument you have to use dot-notation which is a bit akward, especially when multiple functions failed to deploy the very well intended hint to redeploy functions uses dash notation which makes it unusable.

crtl avatar Jun 29 '20 11:06 crtl

Does https://github.com/firebase/firebase-tools/pull/2437 address the issue? If not, feel free to re-open this issue.

taeold avatar Dec 29 '22 19:12 taeold