Skip to content
New issue

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

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

Already on GitHub? # to your account

(cdk bootstrap): Crashes if project name uses a underscore #29640

Closed
edumats opened this issue Mar 28, 2024 · 3 comments
Closed

(cdk bootstrap): Crashes if project name uses a underscore #29640

edumats opened this issue Mar 28, 2024 · 3 comments
Assignees
Labels
bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort p2 package/tools Related to AWS CDK Tools or CLI response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@edumats
Copy link

edumats commented Mar 28, 2024

Describe the bug

I create a project named temporary_urls when I got the following error when I run cdk bootstrap:
jsii.errors.JSIIError: Stack name must match the regular expression: /^[A-Za-z][A-Za-z0-9-]*$/, got 'temporary_urls'

CDK appears to give the project's name to the Stack and it fails if the name does not pass the regex verification, as the _ is not included in the regex.

Expected Behavior

I wouldn't expect CDK to fail like this as it is fairly common to use underscores for project names and the regex rule is quite restrictive. CDK should have alerted me when I defined my name in cdk new-project if my project name has a problem.

Current Behavior

When a project name includes underscores, CDK give an error message that points to the Stack name as the source of the problem, but not the project's name:

jsii.errors.JavaScriptError: 
  Error: Stack name must match the regular expression: /^[A-Za-z][A-Za-z0-9-]*$/, got 'temporary_urls'
      at new Stack (/private/var/folders/v2/6nv9n8754hz1ld_9y0yfy1800000gn/T/jsii-kernel-6qRkb4/node_modules/aws-cdk-lib/core/lib/stack.js:1:2563)
      at Kernel._create (/private/var/folders/v2/6nv9n8754hz1ld_9y0yfy1800000gn/T/tmpmbtzzalu/lib/program.js:8029:29)
      at Kernel.create (/private/var/folders/v2/6nv9n8754hz1ld_9y0yfy1800000gn/T/tmpmbtzzalu/lib/program.js:7764:29)
      at KernelHost.processRequest (/private/var/folders/v2/6nv9n8754hz1ld_9y0yfy1800000gn/T/tmpmbtzzalu/lib/program.js:11017:36)
      at KernelHost.run (/private/var/folders/v2/6nv9n8754hz1ld_9y0yfy1800000gn/T/tmpmbtzzalu/lib/program.js:10977:22)
      at Immediate._onImmediate (/private/var/folders/v2/6nv9n8754hz1ld_9y0yfy1800000gn/T/tmpmbtzzalu/lib/program.js:10978:46)
      at process.processImmediate (node:internal/timers:478:21)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/lilianshimohirao/dudu_projects/chalice_demo/temporary_urls/infrastructure/app.py", line 9, in <module>
    ChaliceApp(app, 'temporary_urls')
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jsii/_runtime.py", line 109, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/Users/lilianshimohirao/dudu_projects/chalice_demo/temporary_urls/infrastructure/stacks/chaliceapp.py", line 20, in __init__
    super().__init__(scope, id, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aws_cdk/__init__.py", line 17783, in __init__
    jsii.create(self.__class__, self, [scope, id, props])
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jsii/_kernel/__init__.py", line 321, in create
    response = self.provider.create(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jsii/_kernel/providers/process.py", line 350, in create
    return self._process.send(request, CreateResponse)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jsii/_kernel/providers/process.py", line 332, in send
    raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: Stack name must match the regular expression: /^[A-Za-z][A-Za-z0-9-]*$/, got 'temporary_urls'

Reproduction Steps

Followed AWS Chalice with CDK tutorial

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.134.0 (build 265d769)

Framework Version

No response

Node.js Version

v20.12.0

OS

MacOS 11.7.9

Language

Python

Language Version

Python 3.10.6

Other information

No response

@edumats edumats added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 28, 2024
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Mar 28, 2024
@tim-finnigan tim-finnigan self-assigned this Apr 1, 2024
@tim-finnigan tim-finnigan added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Apr 1, 2024
@tim-finnigan
Copy link

Thanks for reaching out. Could you provide any more context or information on how you created your project/stack? If you run cdk init as documented here then it should create the valid stack names. That being said, it looks like there are related issues such as #23098 regarding confusion over the validation of underscores in stack names.

@tim-finnigan tim-finnigan added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. effort/medium Medium work item – several days of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Apr 1, 2024
Copy link

github-actions bot commented Apr 4, 2024

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Apr 4, 2024
@github-actions github-actions bot closed this as completed Apr 9, 2024
@aws-cdk-automation
Copy link
Collaborator

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort p2 package/tools Related to AWS CDK Tools or CLI response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants