Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 Functions with uppercase letters are not deployed #7344

Closed
becjit opened this issue Jun 19, 2024 · 13 comments
Closed

V2 Functions with uppercase letters are not deployed #7344

becjit opened this issue Jun 19, 2024 · 13 comments

Comments

@becjit
Copy link

becjit commented Jun 19, 2024

[REQUIRED] Environment info

firebase-tools: [13.11.2]

mac

[REQUIRED] Test case

[REQUIRED] Steps to reproduce

create or deploy any functions with uppercase

[REQUIRED] Expected behavior

Should deploy

[REQUIRED] Actual behavior

v2 function name(s) can only contain lower case letters, numbers, hyphens, and not exceed 62 characters in length

@google-oss-bot
Copy link
Contributor

This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

@KSiejka
Copy link

KSiejka commented Jun 19, 2024

Can you run firebase deploy --debug and check the error logs? It works fine on my end, and all of my function's names use camelCase.

@unxavi
Copy link

unxavi commented Jun 19, 2024

@KSiejka without debug I am hitting this:

Error: Cannot set CPU on the functions my-Function-onCreate because they are GCF gen 1

@KSiejka
Copy link

KSiejka commented Jun 19, 2024

@KSiejka without debug I am hitting this:

Error: Cannot set CPU on the functions my-Function-onCreate because they are GCF gen 1

According to this comment you are trying to downgrade function from v2 to v1. If that's not the case, make sure your firebase-tools are upgraded to the newest version and try importing the v2 functions library to force it to be V2.

@unxavi
Copy link

unxavi commented Jun 19, 2024

@KSiejka i am not trying to downgrade anything, before #7341 start to hit error this morning, the same codebase was deploying.

This is the same codebase that is using a v2 function and it was deploying some hours ago and no changes has occur on the dependencies (which are latests) and not change on the code, but thanks for your comment anyways

@jesus-mg-ios
Copy link

jesus-mg-ios commented Jun 19, 2024

Same here, Is there any ETA fix on this?

@becjit
Copy link
Author

becjit commented Jun 19, 2024

I downgraded firebase-tools to 11.x and it started working

@unxavi
Copy link

unxavi commented Jun 19, 2024

this is working for me now with the latests firebase-tools

@aalej
Copy link
Contributor

aalej commented Jun 19, 2024

Hey folks, I’m currently trying to reproduce this issue. Similar to @KSiejka, I’m able to deploy functions without any issues. For those still encountering this, could you please provide code snippets of the functions you’re trying to deploy?

From what I can gather based on the report, functions names with uppercase letters like below should raise issues during deployments:

const { onRequest } = require("firebase-functions/v2/https");
const logger = require("firebase-functions/logger");
const { onDocumentCreated } = require("firebase-functions/v2/firestore");

exports.helloWorld = onRequest((request, response) => {
   logger.info("Hello logs!", { structuredData: true });
   response.send("Hello from Firebase!");
});

exports.myFunctionOnCreate = onDocumentCreated("users/{userId}", (event) => {
   const snapshot = event.data;
   if (!snapshot) {
       console.log("No data associated with the event");
       return;
   }
   const data = snapshot.data();
   const name = data.name;
   logger.info("Username:", name);
});

Please let me know if I’m missing anything here. I’m using firebase-tools v13.11.2 for deploying functions.

@unxavi
Copy link

unxavi commented Jun 19, 2024

Right now for me is working back again and I have my functions with uppercase letters, for example: "user-Profile-onCreate"

@becjit
Copy link
Author

becjit commented Jun 19, 2024

Hey folks, I’m currently trying to reproduce this issue. Similar to @KSiejka, I’m able to deploy functions without any issues. For those still encountering this, could you please provide code snippets of the functions you’re trying to deploy?

From what I can gather based on the report, functions names with uppercase letters like below should raise issues during deployments:

const { onRequest } = require("firebase-functions/v2/https");
const logger = require("firebase-functions/logger");
const { onDocumentCreated } = require("firebase-functions/v2/firestore");

exports.helloWorld = onRequest((request, response) => {
   logger.info("Hello logs!", { structuredData: true });
   response.send("Hello from Firebase!");
});

exports.myFunctionOnCreate = onDocumentCreated("users/{userId}", (event) => {
   const snapshot = event.data;
   if (!snapshot) {
       console.log("No data associated with the event");
       return;
   }
   const data = snapshot.data();
   const name = data.name;
   logger.info("Username:", name);
});

Please let me know if I’m missing anything here. I’m using firebase-tools v13.11.2 for deploying functions.

This was causing issue

@aalej
Copy link
Contributor

aalej commented Jun 19, 2024

I’m still unable to reproduce the issue. Any chance you could try running firebase deploy --debug while using firebase-tools v13.11.2 to see if the issue would still persist? If the issue still occurs, could you share the contents of the firebase-debug.log file? Please remove any personal identifiable information(PII) before sharing.

Also, I can’t seem to find the exact error message you shared. The closest error message I could find was from

export function functionIdsAreValid(functions: { id: string; platform: string }[]): void {
// TODO: cannot end with a _ or -
const functionName = /^[a-zA-Z][a-zA-Z0-9_-]{0,62}$/;
const invalidIds = functions.filter((fn) => !functionName.test(fn.id));
if (invalidIds.length !== 0) {
const msg =
`${invalidIds.map((f) => f.id).join(", ")} function name(s) can only contain letters, ` +
`numbers, hyphens, and not exceed 62 characters in length`;
throw new FirebaseError(msg);
}
}

But this would raise an error similar to

Error: <INVALID_FUNCTION_NAME> function name(s) can only contain letters, numbers, hyphens, and not exceed 62 characters in length

Could you check if you’re using an older version of firebase-tools? The naming restriction was lifted in v11.29.0.

@aalej aalej added the Needs: Author Feedback Issues awaiting author feedback label Jun 19, 2024
@becjit
Copy link
Author

becjit commented Jun 20, 2024 via email

@google-oss-bot google-oss-bot added Needs: Attention and removed Needs: Author Feedback Issues awaiting author feedback labels Jun 20, 2024
@aalej aalej closed this as completed Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants