Open
Description
Description:
I installed sam cli on ubuntu 22.04, created a new project (sam init) and tried to validate the template without making any changes but get a failure. Please see the steps to reproduce for details:
Steps to reproduce:
- Install Python 3.12 in Ubuntu 22.04 (alongside 3.10 which is standard for Ubuntu 22.04)
- Install sam cli (the latest version I have is 1.119.0)
- Select the options shown below and run the validation at the end without making any changes
~/code/aws/samcli$ sam init
You can preselect a particular runtime or package type when using the `sam init` experience.
Call `sam init --help` to learn more.
Which template source would you like to use?
1 - AWS Quick Start Templates
2 - Custom Template Location
Choice: 1
Choose an AWS Quick Start application template
1 - Hello World Example
2 - Data processing
3 - Hello World Example with Powertools for AWS Lambda
4 - Multi-step workflow
5 - Scheduled task
6 - Standalone function
7 - Serverless API
8 - Infrastructure event management
9 - Lambda Response Streaming
10 - Serverless Connector Hello World Example
11 - Multi-step workflow with Connectors
12 - GraphQLApi Hello World Example
13 - Full Stack
14 - Lambda EFS example
15 - DynamoDB Example
16 - Machine Learning
Template: 1
Use the most popular runtime and package type? (Python and zip) [y/N]: y
Would you like to enable X-Ray tracing on the function(s) in your application? [y/N]: n
Would you like to enable monitoring using CloudWatch Application Insights?
For more info, please view https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch-application-insights.html [y/N]: n
Would you like to set Structured Logging in JSON format on your Lambda functions? [y/N]: n
Project name [sam-app]: samtest
-----------------------
Generating application:
-----------------------
Name: samtest
Runtime: python3.9
Architectures: x86_64
Dependency Manager: pip
Application Template: hello-world
Output Directory: .
Configuration file: samtest/samconfig.toml
Next steps can be found in the README file at samtest/README.md
Commands you can use next
=========================
[*] Create pipeline: cd samtest && sam pipeline init --bootstrap
[*] Validate SAM template: cd samtest && sam validate
[*] Test Function in the Cloud: cd samtest && sam sync --stack-name {stack-name} --watch
~/code/aws/samcli$ cd samtest/
~/code/aws/samcli/samtest$ sam validate
Error: Rule already included: E2531
Traceback:
File "click/core.py", line 1078, in main
File "click/core.py", line 1688, in invoke
File "click/core.py", line 1434, in invoke
File "click/core.py", line 783, in invoke
File "samcli/cli/cli_config_file.py", line 347, in wrapper
File "click/decorators.py", line 92, in new_func
File "click/core.py", line 783, in invoke
File "samcli/lib/telemetry/metric.py", line 185, in wrapped
File "samcli/lib/telemetry/metric.py", line 150, in wrapped
File "samcli/lib/utils/version_checker.py", line 43, in wrapped
File "samcli/cli/main.py", line 95, in wrapper
File "samcli/commands/_utils/cdk_support_decorators.py", line 40, in wrapped
File "samcli/commands/_utils/command_exception_handler.py", line 89, in wrapper_command_exception_handler
File "samcli/commands/_utils/command_exception_handler.py", line 69, in wrapper_command_exception_handler
File "samcli/commands/validate/validate.py", line 60, in cli
File "samcli/commands/validate/validate.py", line 75, in do_cli
File "samcli/commands/validate/validate.py", line 166, in _lint
File "cfnlint/core.py", line 175, in get_matches
(template, rules, errors) = get_template_rules(filename, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "cfnlint/core.py", line 319, in get_template_rules
_build_rule_cache(args)
File "cfnlint/core.py", line 274, in _build_rule_cache
__CACHED_RULES = cfnlint.core.get_rules(
^^^^^^^^^^^^^^^^^^^^^^^
File "cfnlint/core.py", line 160, in get_rules
rules.create_from_directory(rules_path)
File "cfnlint/rules/__init__.py", line 595, in create_from_directory
self.extend(result)
File "cfnlint/rules/__init__.py", line 304, in extend
self.register(rule)
File "cfnlint/rules/__init__.py", line 291, in register
raise DuplicateRuleError(rule_id=rule.id)
An unexpected error was encountered while executing "sam validate".
Search for an existing issue:
https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20validate%20-%20DuplicateRuleError
Or create a bug report:
https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20validate%20-%20DuplicateRuleError
~/code/aws/samcli/samtest$
Observed result:
The out of the box validation of a standard template fails.
The system also does not ask to select the version of python to use and defaults to a version that is not even in the system (other template I tried, Serverless Connector Hello World Example, did ask me to select the version of python I want to use but ended up with the same error irrespective of which version I choose (3.10 which is default on my machine or 3.12 that I installed alongside).
Expected result:
The out of the box template should be valid.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Ubuntu 22.04
sam --version
: 1.119.0- AWS region: irrelevant (but us-east-1)
`sam --info`
{
"version": "1.119.0",
"system": {
"python": "3.11.8",
"os": "Linux-6.5.0-35-generic-x86_64-with-glibc2.35"
},
"additional_dependencies": {
"docker_engine": "Not available",
"aws_cdk": "Not available",
"terraform": "Not available"
},
"available_beta_feature_env_vars": [
"SAM_CLI_BETA_FEATURES",
"SAM_CLI_BETA_BUILD_PERFORMANCE",
"SAM_CLI_BETA_TERRAFORM_SUPPORT",
"SAM_CLI_BETA_RUST_CARGO_LAMBDA"
]
}
More environment details
python --version
Python 3.10.12
python3 --version
Python 3.10.12
python3.12 --version
Python 3.12.4
aws --version
aws-cli/2.14.5 Python/3.11.6 Linux/6.5.0-35-generic exe/x86_64.ubuntu.22 prompt/off
docker --version
Docker version 26.1.4, build 5650f9b