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

Create Function - package.json name does not match regexp warning #7905

Closed
4 tasks done
GeorgeBellTMH opened this issue Aug 6, 2021 · 8 comments · Fixed by #7988 or #9868
Closed
4 tasks done

Create Function - package.json name does not match regexp warning #7905

GeorgeBellTMH opened this issue Aug 6, 2021 · 8 comments · Fixed by #7988 or #9868
Labels
feature-request Request a new feature functions Issues tied to the functions category good first issue Good for newcomers

Comments

@GeorgeBellTMH
Copy link

Before opening, please confirm:

  • I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

latest

Amplify CLI Version

latest

What operating system are you using?

macOS

Amplify Categories

function

Amplify Commands

add

Describe the bug

When you create an amplify function with capitals, there is a warning that appears for the name field in package.json that is created...

String does not match the pattern of "^(?:@[a-z0-9-~][a-z0-9-.]*/)?[a-z0-9-][a-z0-9-.~]*$".

Expected behavior

No warning should appear...name field should be modified to lowercase...

Reproduction steps

Create a function called testFunction

GraphQL schema(s)

# Put schemas below this line

Log output

# Put your logs below this line


Additional information

No response

@jhockett jhockett added functions Issues tied to the functions category pending-triage Issue is pending triage labels Aug 6, 2021
@josefaidt josefaidt self-assigned this Aug 6, 2021
@josefaidt josefaidt added this to Triaging in DSE Issues Triaging Aug 6, 2021
@josefaidt
Copy link
Contributor

Hey @GeorgeBellTMH 👋 thanks for raising this! I also see this warning from npm regarding an invalid name field value. Thankfully this does not impact our deployments or usage, however it does not follow the spec for package.json name field. Marking this as a feature request to force the package name to all lowercase when adding a function with capital letters in the name.

@josefaidt josefaidt added feature-request Request a new feature and removed pending-triage Issue is pending triage labels Aug 6, 2021
@josefaidt josefaidt moved this from Triaging to Triage Complete in DSE Issues Triaging Aug 6, 2021
@josefaidt josefaidt removed their assignment Aug 6, 2021
@jhockett jhockett added the good first issue Good for newcomers label Aug 9, 2021
@studpeps
Copy link
Contributor

Hey @GeorgeBellTMH and @josefaidt, I am trying to reproduce the issue but have been unable to, has this been arising when deploying or when creating the function locally
I did the following steps to produce the bug:

$ amplify add function
? Select which capability you want to add: Lambda function (serverless function)
? Provide an AWS Lambda function name: testFunction
? Choose the runtime that you want to use: NodeJS
? Choose the function template that you want to use: Hello World

Available advanced settings:

  • Resource access permissions
  • Scheduled recurring invocation
  • Lambda layers configuration
  • Environment variables configuration
  • Secret values configuration

? Do you want to configure advanced settings? No
? Do you want to edit the local lambda function now? No
Successfully added resource testFunction locally.

It gives me a success message for lambda function

@josefaidt
Copy link
Contributor

Hey @studpeps 👋 this is an npm warning and does not impact creation or pushes of the Lambda function. It can be found in the function's package.json file:

image

Reference for package.json "name" specification

@studpeps
Copy link
Contributor

Oh yes right, thank you @josefaidt

@cjihrig cjihrig added this to In-Progress in MLH-2021 Aug 23, 2021
MLH-2021 automation moved this from In-Progress to Done Aug 25, 2021
@cjihrig cjihrig reopened this Aug 27, 2021
DSE Issues Triaging automation moved this from Triage Complete to Triaging Aug 27, 2021
@cjihrig
Copy link
Contributor

cjihrig commented Aug 27, 2021

I've opened #8051 as a revert. I do think we should address this issue, but I think we can do it in a less breaking way.

@cjihrig cjihrig removed this from Done in MLH-2021 Aug 27, 2021
@GeorgeBellTMH
Copy link
Author

At the least can we implement this on new functions? I would also suggest asking if it should be fixed on updates...there doesn't seem to be a lot of good reasons to have an incorrect package.json...

@josefaidt josefaidt moved this from Triaging to Triage Complete in DSE Issues Triaging Sep 16, 2021
@fossamagna
Copy link
Contributor

I've opened #8051 as a revert. I do think we should address this issue, but I think we can do it in a less breaking way.

Hey @cjihrig. I considered it as follows.

  • We can contain upper case characters in function name as before
  • Only name in package.json will be changed to lower case.

What do you think on this?

@cjihrig
Copy link
Contributor

cjihrig commented Feb 25, 2022

@fossamagna that could potentially work.

fossamagna added a commit to fossamagna/amplify-cli that referenced this issue Feb 27, 2022
…o lower case in package.json

improve function name matches spec for package.json name field

fix aws-amplify#7905
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request a new feature functions Issues tied to the functions category good first issue Good for newcomers
Projects
No open projects
DSE Issues Triaging
Triage Complete
6 participants