You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Performing a sam init against a custom template location that has multiple project templates results in a cookiecutter error. This only started happening with a recent update to the sam cli. It did not occur in v 1.95.0. I only started seeing it in 1.103.0.
You can see the error by attempting to init either of these 2 projects in aws-samples
sam init --location gh:aws-samples/cookiecutter-aws-sam-rust
sam init --location gh:aws-samples/aws-sam-swift
Steps to reproduce:
Update your SAM CLI to the latest version (1.103)
Initialize a new project with either of these templates
sam init --location gh:aws-samples/cookiecutter-aws-sam-rust
sam init --location gh:aws-samples/aws-sam-swift
Observed result:
You get a cookiecutter error
Error: 'NoneType' object has no attribute 'group'
Traceback:
File "/usr/local/opt/python-click/lib/python3.12/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/usr/local/opt/python-click/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/opt/python-click/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/opt/python-click/lib/python3.12/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.103.0/libexec/lib/python3.12/site-packages/samcli/cli/cli_config_file.py", line 347, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.103.0/libexec/lib/python3.12/site-packages/samcli/commands/init/command.py", line 102, in wrapped
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/opt/python-click/lib/python3.12/site-packages/click/decorators.py", line 92, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/opt/python-click/lib/python3.12/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.103.0/libexec/lib/python3.12/site-packages/samcli/lib/telemetry/metric.py", line 184, in wrapped
raise exception # pylint: disable=raising-bad-type
^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.103.0/libexec/lib/python3.12/site-packages/samcli/lib/telemetry/metric.py", line 149, in wrapped
return_value = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.103.0/libexec/lib/python3.12/site-packages/samcli/lib/utils/version_checker.py", line 42, in wrapped
actual_result = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.103.0/libexec/lib/python3.12/site-packages/samcli/cli/main.py", line 95, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.103.0/libexec/lib/python3.12/site-packages/samcli/commands/init/command.py", line 265, in cli
do_cli(
File "/usr/local/Cellar/aws-sam-cli/1.103.0/libexec/lib/python3.12/site-packages/samcli/commands/init/command.py", line 346, in do_cli
do_generate(
File "/usr/local/Cellar/aws-sam-cli/1.103.0/libexec/lib/python3.12/site-packages/samcli/commands/init/init_generator.py", line 24, in do_generate
generate_project(
File "/usr/local/Cellar/aws-sam-cli/1.103.0/libexec/lib/python3.12/site-packages/samcli/lib/init/__init__.py", line 111, in generate_project
cookiecutter(**params)
File "/usr/local/opt/cookiecutter/libexec/lib/python3.12/site-packages/cookiecutter/main.py", line 142, in cookiecutter
nested_template = choose_nested_template(context, repo_dir, no_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/opt/cookiecutter/libexec/lib/python3.12/site-packages/cookiecutter/prompt.py", line 361, in choose_nested_template
template = re.search(r'\((.+)\)', val).group(1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expected result:
In prior versions of the CLI (at least 1.95.0) the project generated the folder structure without error. I'm not sure which CLI version this error started occuring. It is happening in 1.103.0
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Might it have something to do with SAM CLI upgrading to v2.5 of cookiecutter? I see a reference to Implement new style for nested templates config in the release notes for cookiecutter 2.5.0. Both of these SAM aws-samples use multiple templates for the user to choose from.
I determined this is due to a new way cookiecutter configures multiple templates in one repo as of v 2.2. Additnal changes were implemented in v2.5. SAM CLI 1.103.0 updates cookie cutter to v2.5. Once I reorganized my repo to the new template folder structure, it works. I suspect this will affect anyone who published a SAM Template Project prior to Juky 2023 when the new formats were introduced.
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Description:
Performing a sam init against a custom template location that has multiple project templates results in a cookiecutter error. This only started happening with a recent update to the sam cli. It did not occur in v 1.95.0. I only started seeing it in 1.103.0.
You can see the error by attempting to init either of these 2 projects in aws-samples
Steps to reproduce:
Update your SAM CLI to the latest version (1.103)
Initialize a new project with either of these templates
Observed result:
You get a cookiecutter error
Expected result:
In prior versions of the CLI (at least 1.95.0) the project generated the folder structure without error. I'm not sure which CLI version this error started occuring. It is happening in 1.103.0
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: SAM CLI, version 1.103.0Add --debug flag to command you are running
The text was updated successfully, but these errors were encountered: