Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions samcli/local/lambdafn/config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""
Lambda Function configuration data required by the runtime
"""
import ast

from samcli.commands.local.cli_common.user_exceptions import InvalidSamTemplateException
from .env_vars import EnvironmentVariables

Expand Down Expand Up @@ -51,13 +49,9 @@ def __init__(self, name, runtime, handler, code_abs_path, layers, memory=None, t

if not isinstance(self.timeout, int):
try:
self.timeout = ast.literal_eval(self.timeout)

# Guard against float values like "3.2"
if not isinstance(self.timeout, int):
raise InvalidSamTemplateException("Invalid Number for Timeout: {}".format(self.timeout))
self.timeout = int(self.timeout)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this handle None / empty string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int(None) raises TypeError, int('') raises ValueError


except (ValueError, SyntaxError, TypeError):
except (ValueError, TypeError):
raise InvalidSamTemplateException("Invalid Number for Timeout: {}".format(self.timeout))

if not env_vars:
Expand Down