diff --git a/requirements/base.txt b/requirements/base.txt index 033f34b1ce..9f3df011c9 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -31,7 +31,7 @@ regex!=2021.10.8 tzlocal==5.2 #Adding cfn-lint dependency for SAM validate -cfn-lint~=1.18.4 +cfn-lint~=1.19.0 # Type checking boto3 objects boto3-stubs[apigateway,cloudformation,ecr,iam,lambda,s3,schemas,secretsmanager,signer,stepfunctions,sts,xray,sqs,kinesis]==1.35.56 diff --git a/requirements/reproducible-linux.txt b/requirements/reproducible-linux.txt index 5ab27687c0..993eb44ac0 100644 --- a/requirements/reproducible-linux.txt +++ b/requirements/reproducible-linux.txt @@ -129,9 +129,9 @@ cffi==1.17.1 \ --hash=sha256:f7f5baafcc48261359e14bcd6d9bff6d4b28d9103847c9e136694cb0501aef87 \ --hash=sha256:fc48c783f9c87e60831201f2cce7f3b2e4846bf4d8728eabe54d60700b318a0b # via cryptography -cfn-lint==1.18.4 \ - --hash=sha256:73dadc33d6a91c69651cb08fe919138ab4e2f6cf1be1e361f7c6dcbccd1527ba \ - --hash=sha256:76741e76fa26f31bfacc3eb465eddd93ad535838d84fbc6dd092817d8e22d57f +cfn-lint==1.19.0 \ + --hash=sha256:63835e083f7831e54c512bce4808754df221b5895aed9a114c71879d1cc4ebff \ + --hash=sha256:9c43a6b866915df6d2ac5584000ef05e53c67624809808c2cebd3dc6154b7c14 # via aws-sam-cli (setup.py) chardet==5.2.0 \ --hash=sha256:1b3b6ff479a8c414bc3fa2c0852995695c4a026dcd6d0633b2dd092ca39c1cf7 \ diff --git a/requirements/reproducible-mac.txt b/requirements/reproducible-mac.txt index 93b4ad50fb..55d0d45685 100644 --- a/requirements/reproducible-mac.txt +++ b/requirements/reproducible-mac.txt @@ -147,9 +147,9 @@ cffi==1.17.1 \ --hash=sha256:f7f5baafcc48261359e14bcd6d9bff6d4b28d9103847c9e136694cb0501aef87 \ --hash=sha256:fc48c783f9c87e60831201f2cce7f3b2e4846bf4d8728eabe54d60700b318a0b # via cryptography -cfn-lint==1.18.4 \ - --hash=sha256:73dadc33d6a91c69651cb08fe919138ab4e2f6cf1be1e361f7c6dcbccd1527ba \ - --hash=sha256:76741e76fa26f31bfacc3eb465eddd93ad535838d84fbc6dd092817d8e22d57f +cfn-lint==1.19.0 \ + --hash=sha256:63835e083f7831e54c512bce4808754df221b5895aed9a114c71879d1cc4ebff \ + --hash=sha256:9c43a6b866915df6d2ac5584000ef05e53c67624809808c2cebd3dc6154b7c14 # via aws-sam-cli (setup.py) chardet==5.2.0 \ --hash=sha256:1b3b6ff479a8c414bc3fa2c0852995695c4a026dcd6d0633b2dd092ca39c1cf7 \ diff --git a/requirements/reproducible-win.txt b/requirements/reproducible-win.txt index 4217a5bf63..fd42713db8 100644 --- a/requirements/reproducible-win.txt +++ b/requirements/reproducible-win.txt @@ -129,9 +129,9 @@ cffi==1.17.1 \ --hash=sha256:f7f5baafcc48261359e14bcd6d9bff6d4b28d9103847c9e136694cb0501aef87 \ --hash=sha256:fc48c783f9c87e60831201f2cce7f3b2e4846bf4d8728eabe54d60700b318a0b # via cryptography -cfn-lint==1.18.4 \ - --hash=sha256:73dadc33d6a91c69651cb08fe919138ab4e2f6cf1be1e361f7c6dcbccd1527ba \ - --hash=sha256:76741e76fa26f31bfacc3eb465eddd93ad535838d84fbc6dd092817d8e22d57f +cfn-lint==1.19.0 \ + --hash=sha256:63835e083f7831e54c512bce4808754df221b5895aed9a114c71879d1cc4ebff \ + --hash=sha256:9c43a6b866915df6d2ac5584000ef05e53c67624809808c2cebd3dc6154b7c14 # via aws-sam-cli (setup.py) chardet==5.2.0 \ --hash=sha256:1b3b6ff479a8c414bc3fa2c0852995695c4a026dcd6d0633b2dd092ca39c1cf7 \ diff --git a/samcli/__init__.py b/samcli/__init__.py index ceeffa3bb4..6acc974f0a 100644 --- a/samcli/__init__.py +++ b/samcli/__init__.py @@ -2,4 +2,4 @@ SAM CLI version """ -__version__ = "1.128.0" +__version__ = "1.129.0" diff --git a/samcli/commands/init/init_templates.py b/samcli/commands/init/init_templates.py index b1d1d55a01..bbc3505e1a 100644 --- a/samcli/commands/init/init_templates.py +++ b/samcli/commands/init/init_templates.py @@ -283,16 +283,21 @@ def _get_manifest(self): """ try: response = requests.get(MANIFEST_URL, timeout=10) - body = response.text - # if the commit is not exist then MANIFEST_URL will be invalid, fall back to use manifest in latest commit - if response.status_code == Status.NOT_FOUND.value: - LOG.warning( - "Request to MANIFEST_URL: %s failed, the commit hash in this url maybe invalid, " - "Using manifest.json in the latest commit instead.", - MANIFEST_URL, - ) + if not response.ok: + # if the commit is not exist then MANIFEST_URL will be invalid, + # fall back to use manifest in latest commit + if response.status_code == Status.NOT_FOUND.value: + LOG.warning( + "Request to MANIFEST_URL: %s failed, the commit hash in this url maybe invalid, " + "Using manifest.json in the latest commit instead.", + MANIFEST_URL, + ) + else: + LOG.debug( + "Request to MANIFEST_URL: %s failed, with %s status code", MANIFEST_URL, response.status_code + ) raise ManifestNotFoundException() - + body = response.text except (requests.Timeout, requests.ConnectionError, ManifestNotFoundException): LOG.debug("Request to get Manifest failed, attempting to clone the repository") self.clone_templates_repo() diff --git a/samcli/runtime_config.json b/samcli/runtime_config.json index c9e0bf3d1b..02160cc202 100644 --- a/samcli/runtime_config.json +++ b/samcli/runtime_config.json @@ -1,3 +1,3 @@ { - "app_template_repo_commit": "994ec01c08fa415ed20258d72cb7f750b8b8211d" + "app_template_repo_commit": "a22d509a91e0ceca3eb596ab13d5ebe76ff0a894" } diff --git a/tests/integration/validate/test_validate_command.py b/tests/integration/validate/test_validate_command.py index 453d83165a..34c81068f8 100644 --- a/tests/integration/validate/test_validate_command.py +++ b/tests/integration/validate/test_validate_command.py @@ -182,6 +182,7 @@ def test_lint_supported_runtimes(self): "python3.10", "python3.11", "python3.12", + "python3.13", "ruby3.2", "ruby3.3", ] diff --git a/tests/unit/commands/init/test_cli.py b/tests/unit/commands/init/test_cli.py index 8be3d92e10..7ea5ff3609 100644 --- a/tests/unit/commands/init/test_cli.py +++ b/tests/unit/commands/init/test_cli.py @@ -9,7 +9,7 @@ from pathlib import Path from typing import Dict, Any from unittest import TestCase -from unittest.mock import patch, ANY +from unittest.mock import patch, ANY, Mock import botocore.exceptions import click @@ -2204,6 +2204,24 @@ def test_must_return_runtime_from_base_image_name(self): runtime = get_runtime(IMAGE, base_image) self.assertEqual(runtime, expected_runtime[index]) + @patch("samcli.commands.init.init_templates.requests") + @patch.object(InitTemplates, "__init__", MockInitTemplates.__init__) + def test_must_fallback_for_non_ok_http_response(self, requests_mock): + requests_mock.get.return_value = Mock(ok=False) + requests_mock.Timeout = requests.Timeout + requests_mock.ConnectionError = requests.ConnectionError + + template = InitTemplates() + with mock.patch.object( + template, "clone_templates_repo", wraps=template.clone_templates_repo + ) as mocked_clone_templates_repo: + with mock.patch.object( + template, "get_manifest_path", wraps=template.get_manifest_path + ) as mocked_get_manifest_path: + template.get_preprocessed_manifest() + mocked_clone_templates_repo.assert_called_once() + mocked_get_manifest_path.assert_called_once() + @patch("samcli.commands.init.init_templates.InitTemplates._get_manifest") @patch.object(InitTemplates, "__init__", MockInitTemplates.__init__) def test_must_process_manifest(self, _get_manifest_mock):