Skip to content

Bug: Validate with Lint Failing for Python 3.11 #5652

Description

@osjerick

Description:

Python 3.11 support has been added in aws/aws-lambda-base-images#62 but SAM validation of the SAM template fails when --lint is passed and Python 3.11 is used as runtime:

Command:

sam validate --lint

Output:

E3030 You must specify a valid value for Runtime (python3.11). Valid values are ["dotnet6", "dotnetcore1.0", "dotnetcore2.0", "dotnetcore2.1", "dotnetcore3.1", "go1.x", "java11", "java17", "java8", "java8.al2", "nodejs", "nodejs10.x", "nodejs12.x", "nodejs14.x", "nodejs16.x", "nodejs18.x", "nodejs4.3", "nodejs4.3-edge", "nodejs6.10", "nodejs8.10", "provided", "provided.al2", "python2.7", "python3.10", "python3.6", "python3.7", "python3.8", "python3.9", "ruby2.5", "ruby2.7", "ruby3.2"]

Basic SAM validation passes successfully (sam validate).

Steps to reproduce:

Init a sample app:

sam init --runtime python3.11

This runs successfully as python3.11 is valid runtime.

Run validation:

cd sam-app
sam validate --lint

Observed result (with --debug):

2023-07-31 12:52:48,667 | Config file location: /Users/jerick/Downloads/test/sam-app/samconfig.toml
2023-07-31 12:52:48,669 | Loading configuration values from [default.['validate'].parameters] (env.command_name.section)
in config file at '/Users/jerick/Downloads/test/sam-app/samconfig.toml'...
2023-07-31 12:52:48,669 | Configuration values successfully loaded.
2023-07-31 12:52:48,670 | Configuration values are: {'stack_name': 'sam-app', 'lint': False}
2023-07-31 12:52:48,672 | Using SAM Template at /Users/jerick/Downloads/test/sam-app/template.yaml
2023-07-31 12:52:48,692 | Using config file: samconfig.toml, config environment: default
2023-07-31 12:52:48,693 | Expand command line arguments to:
2023-07-31 12:52:48,693 | --template_file=/Users/jerick/Downloads/test/sam-app/template.yaml --lint
2023-07-31 12:52:49,161 - cfnlint - DEBUG - Looking for CFLINTRC before attempting to load
2023-07-31 12:52:49,161 - cfnlint - DEBUG - Validating User CFNLINTRC
2023-07-31 12:52:49,161 - cfnlint - DEBUG - Validating CFNLINTRC config with given JSONSchema
2023-07-31 12:52:49,161 - cfnlint - DEBUG - Schema used: {'$id': 'https://github.com/aws-cloudformation/cfn-python-lint/blob/main/src/cfnlint/data/CfnLintCli/config/schema.json', '$schema': 'http://json-schema.org/draft-07/schema#', 'additionalProperties': False, 'description': 'CFNLINTRC configuration schema', 'properties': {'append_rules': {'description': 'Location of directories to append rules from', 'items': {'type': 'string'}, 'type': 'array'}, 'configure_rules': {'additionalProperties': False, 'description': 'Configure rules', 'patternProperties': {'^.*$': {'patternProperties': {'^.*$': {'anyOf': [{'type': 'string'}, {'type': 'integer'}, {'type': 'boolean'}, {'items': {'type': 'string'}, 'type': 'array'}, {'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'boolean'}]}}, 'type': 'object'}}, 'type': 'object'}, 'custom_rules': {'description': 'custom rule file to use', 'type': 'string'}, 'ignore_checks': {'description': 'List of checks to ignore', 'items': {'type': 'string'}, 'type': 'array'}, 'ignore_templates': {'description': 'Templates to ignore', 'items': {'type': 'string'}, 'type': 'array'}, 'include_checks': {'description': 'List of checks to include', 'items': {'type': 'string'}, 'type': 'array'}, 'mandatory_checks': {'description': 'List of mandatory checks to enforce', 'items': {'type': 'string'}, 'type': 'array'}, 'merge_configs': {'description': 'Merges lists between configuration layers', 'type': 'boolean'}, 'output_file': {'description': 'Path to the file to write the main output to', 'type': 'string'}, 'override_spec': {'description': 'Path to spec file to override with', 'type': 'string'}, 'regions': {'description': 'Regions to test against', 'items': {'type': 'string'}, 'type': 'array'}, 'registry_schemas': {'description': 'One or more directories of CloudFormation Registry Resource Schemas', 'items': {'type': 'string'}, 'type': 'array'}, 'templates': {'description': 'Templates to lint', 'items': {'type': 'string'}, 'type': 'array'}}, 'title': 'CFNLINTRC JSON Schema', 'type': 'object'}
2023-07-31 12:52:49,161 - cfnlint - DEBUG - Config used: {}
2023-07-31 12:52:49,163 - cfnlint - DEBUG - CFNLINTRC looks valid!
2023-07-31 12:52:49,164 - cfnlint - DEBUG - Validating Project CFNLINTRC
2023-07-31 12:52:49,164 - cfnlint - DEBUG - Validating CFNLINTRC config with given JSONSchema
2023-07-31 12:52:49,164 - cfnlint - DEBUG - Schema used: {'$id': 'https://github.com/aws-cloudformation/cfn-python-lint/blob/main/src/cfnlint/data/CfnLintCli/config/schema.json', '$schema': 'http://json-schema.org/draft-07/schema#', 'additionalProperties': False, 'description': 'CFNLINTRC configuration schema', 'properties': {'append_rules': {'description': 'Location of directories to append rules from', 'items': {'type': 'string'}, 'type': 'array'}, 'configure_rules': {'additionalProperties': False, 'description': 'Configure rules', 'patternProperties': {'^.*$': {'patternProperties': {'^.*$': {'anyOf': [{'type': 'string'}, {'type': 'integer'}, {'type': 'boolean'}, {'items': {'type': 'string'}, 'type': 'array'}, {'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'boolean'}]}}, 'type': 'object'}}, 'type': 'object'}, 'custom_rules': {'description': 'custom rule file to use', 'type': 'string'}, 'ignore_checks': {'description': 'List of checks to ignore', 'items': {'type': 'string'}, 'type': 'array'}, 'ignore_templates': {'description': 'Templates to ignore', 'items': {'type': 'string'}, 'type': 'array'}, 'include_checks': {'description': 'List of checks to include', 'items': {'type': 'string'}, 'type': 'array'}, 'mandatory_checks': {'description': 'List of mandatory checks to enforce', 'items': {'type': 'string'}, 'type': 'array'}, 'merge_configs': {'description': 'Merges lists between configuration layers', 'type': 'boolean'}, 'output_file': {'description': 'Path to the file to write the main output to', 'type': 'string'}, 'override_spec': {'description': 'Path to spec file to override with', 'type': 'string'}, 'regions': {'description': 'Regions to test against', 'items': {'type': 'string'}, 'type': 'array'}, 'registry_schemas': {'description': 'One or more directories of CloudFormation Registry Resource Schemas', 'items': {'type': 'string'}, 'type': 'array'}, 'templates': {'description': 'Templates to lint', 'items': {'type': 'string'}, 'type': 'array'}}, 'title': 'CFNLINTRC JSON Schema', 'type': 'object'}
2023-07-31 12:52:49,164 - cfnlint - DEBUG - Config used: {}
2023-07-31 12:52:49,164 - cfnlint - DEBUG - CFNLINTRC looks valid!
2023-07-31 12:52:49,164 - cfnlint - DEBUG - User configuration loaded as
2023-07-31 12:52:49,164 - cfnlint - DEBUG - {}
2023-07-31 12:52:49,164 - cfnlint - DEBUG - Project configuration loaded as
2023-07-31 12:52:49,164 - cfnlint - DEBUG - {}
2023-07-31 12:52:49,164 - cfnlint - DEBUG - Merging configurations...
E3030 You must specify a valid value for Runtime (python3.11). Valid values are ["dotnet6", "dotnetcore1.0", "dotnetcore2.0", "dotnetcore2.1", "dotnetcore3.1", "go1.x", "java11", "java17", "java8", "java8.al2", "nodejs", "nodejs10.x", "nodejs12.x", "nodejs14.x", "nodejs16.x", "nodejs18.x", "nodejs4.3", "nodejs4.3-edge", "nodejs6.10", "nodejs8.10", "provided", "provided.al2", "python2.7", "python3.10", "python3.6", "python3.7", "python3.8", "python3.9", "ruby2.5", "ruby2.7", "ruby3.2"]
/Users/jerick/Downloads/test/sam-app/template.yaml:15:5

2023-07-31 12:52:49,221 | Telemetry endpoint configured to be
https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2023-07-31 12:52:49,247 | Telemetry endpoint configured to be
https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2023-07-31 12:52:49,248 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId':
'435387cf-29b2-45e2-bec6-9c19d152c5b5', 'installationId': 'f8c4f9e3-cf89-4c08-9a65-7c81cf0b2bf7', 'sessionId':
'33993e74-014c-42c6-ac6e-5219b5526695', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.4',
'samcliVersion': '1.94.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam
validate', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName':
'593ab2ca51e925b9f6c2f258bc55ed5926cf6d2c78239a685d65907e4ec7edd3', 'initialCommit': None}, 'duration': 528,
'exitReason': 'LinterRuleMatchedException', 'exitCode': 1}}]}
2023-07-31 12:52:49,248 | Unable to find Click Context for getting session_id.
2023-07-31 12:52:49,250 | Sending Telemetry: {'metrics': [{'events': {'requestId':
'2771215b-25d2-49d2-b21f-d30c7a020cc3', 'installationId': 'f8c4f9e3-cf89-4c08-9a65-7c81cf0b2bf7', 'sessionId':
'33993e74-014c-42c6-ac6e-5219b5526695', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.4',
'samcliVersion': '1.94.0', 'metricSpecificAttributes': {'events': [{'event_name': 'SamConfigFileExtension',
'event_value': '.toml', 'thread_id': '92fc7274325345ca803ca25b797a44a2', 'time_stamp': '2023-07-31 16:52:48.667',
'exception_name': None}, {'event_name': 'UsedFeature', 'event_value': 'CFNLint', 'thread_id':
'995e6da628f94c1396d249364daf54b2', 'time_stamp': '2023-07-31 16:52:49.160', 'exception_name': None}]}}}]}
2023-07-31 12:52:49,842 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443):
Read timed out. (read timeout=0.1)
2023-07-31 12:52:49,845 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443):
Read timed out. (read timeout=0.1)
Error: Linting failed. At least one linting rule was matched to the provided template.

Expected result:

The validation with --lint must pass, and output ... is a valid SAM Template.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

{
  "version": "1.94.0",
  "system": {
    "python": "3.11.4",
    "os": "macOS-13.5-arm64-arm-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "24.0.2",
    "aws_cdk": "Not available",
    "terraform": "1.5.4"
  },
  "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"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    stage/waiting-for-releaseFix has been merged to develop and is waiting for a release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions