Skip to content

wasp new accepts invalid names #4763

Description

@infomiho

wasp new prints these rules when a name fails:

The project's name is not in a valid format! The project's name:
  - must start with a letter or an underscore
  - must contain only letters, numbers, dashes, or underscores
  - must not be a Wasp keyword

But validation runs on the converted app name (kebabToCamelCase), which can repair violations - while the directory is created from the raw name:

$ wasp new -- -app     # converts to "App" -> passes validation
$ wasp new "app'"      # trailing ' allowed by identifier rule

Both proceed into template creation and leave shell-hostile directories behind:

🐝 --- Creating your project from the "basic" template... -------------------------
./-app
🐝 --- Creating your project from the "basic" template... -------------------------
./app'

Cause: parseWaspProjectNameIntoAppName validates the converted name (cli/src/Wasp/Cli/Command/CreateNewProject/ProjectDescription.hs:98) using isValidWaspIdentifier (src/Wasp/Analyzer/AST.hs:45), which also permits trailing ' primes the printed rules never mention.

Fix options: validate the raw project name against the printed rules as well, or extend the rules text to describe actual acceptance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions