Skip to content

Commit f37ba41

Browse files
authored
fix(apigw): ValueError is not caught by int() (#2305)
1 parent b1b3a9c commit f37ba41

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

samtranslator/model/apigateway.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def _is_missing_identity_source(self, identity):
285285
try:
286286
ttl_int = int(ttl)
287287
# this will catch if ttl is None and not convertable to an int
288-
except TypeError:
288+
except (TypeError, ValueError):
289289
# previous behavior before trying to read ttl
290290
return required_properties_missing
291291

tests/validator/input/api/error_auth_cognito.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ Resources:
4343
Identity:
4444
ReauthorizeEvery: "3"
4545
UserPoolArn: User.pool.arn
46+
CognitoIdentityReauthorizeEveryValueError:
47+
Identity:
48+
ReauthorizeEvery: NotANumber
49+
UserPoolArn: User.pool.arn
4650
CognitoIdentityReauthorizeEveryTooHigh:
4751
Identity:
4852
ReauthorizeEvery: 3601

tests/validator/output/api/error_auth_cognito.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"[Resources.MyApi.Properties.Auth.Authorizers.CognitoIdentityReauthorizeEveryNotInt.Identity.ReauthorizeEvery] '3' is not of type 'integer', 'intrinsic'",
1010
"[Resources.MyApi.Properties.Auth.Authorizers.CognitoIdentityReauthorizeEveryTooHigh.Identity.ReauthorizeEvery] 3601 is greater than the maximum of 3600",
1111
"[Resources.MyApi.Properties.Auth.Authorizers.CognitoIdentityReauthorizeEveryTooLow.Identity.ReauthorizeEvery] 0 is less than the minimum of 1",
12+
"[Resources.MyApi.Properties.Auth.Authorizers.CognitoIdentityReauthorizeEveryValueError.Identity.ReauthorizeEvery] 'NotANumber' is not of type 'integer', 'intrinsic'",
1213
"[Resources.MyApi.Properties.Auth.Authorizers.CognitoIdentityValidationExpressionEmpty.Identity.ValidationExpression] Must not be empty",
1314
"[Resources.MyApi.Properties.Auth.Authorizers.CognitoIdentityValidationExpressionNotString.Identity.ValidationExpression] 3 is not of type 'string'",
1415
"[Resources.MyApi.Properties.Auth.Authorizers.CognitoUserPoolArnEmpty.UserPoolArn] Must not be empty",

0 commit comments

Comments
 (0)