Skip to content

Commit

Permalink
fix(start-lambda): Fix for stackTrace not returned in new Lambda cont…
Browse files Browse the repository at this point in the history
…ainers. (#1642)

Original PR #1620
Initial reverted PR #1621

This reverts commit c75944e.
  • Loading branch information
jfuss committed Dec 11, 2019
1 parent 0ce744f commit eaf6e86
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
12 changes: 11 additions & 1 deletion samcli/commands/deploy/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,17 @@ def do_cli(

read_config_showcase(template_file=template_file)

guided_stack_name, guided_s3_bucket, guided_s3_prefix, guided_region, guided_profile, changeset_decision, _capabilities, _parameter_overrides, save_to_config = guided_deploy(
(
guided_stack_name,
guided_s3_bucket,
guided_s3_prefix,
guided_region,
guided_profile,
changeset_decision,
_capabilities,
_parameter_overrides,
save_to_config,
) = guided_deploy(
stack_name, s3_bucket, region, profile, confirm_changeset, _parameter_override_keys, parameter_overrides
)

Expand Down
7 changes: 3 additions & 4 deletions samcli/local/services/base_local_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,14 @@ def is_lambda_error_response(lambda_response):

# This is a best effort attempt to determine if the output (lambda_response) from the container was an
# Error/Exception that was raised/returned/thrown from the container. To ensure minimal false positives in
# this checking, we check for all three keys that can occur in Lambda raised/thrown/returned an
# this checking, we check for all the keys that can occur in Lambda raised/thrown/returned an
# Error/Exception. This still risks false positives when the data returned matches exactly a dictionary with
# the keys 'errorMessage', 'errorType' and 'stackTrace'.
# the keys 'errorMessage' and 'errorType'.
if (
isinstance(lambda_response_dict, dict)
and len(lambda_response_dict) == 3
and len(lambda_response_dict) in [2, 3]
and "errorMessage" in lambda_response_dict
and "errorType" in lambda_response_dict
and "stackTrace" in lambda_response_dict
):
is_lambda_user_error_response = True
except ValueError:
Expand Down
1 change: 1 addition & 0 deletions tests/unit/local/services/test_base_local_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def test_get_lambda_output_extracts_response(self, test_case_name, stdout_data,
param(
'{"errorMessage": "has a message", "stackTrace": "has a stacktrace", "errorType": "has a type"}', True
),
param('{"errorMessage": "has a message", "errorType": "has a type"}', True),
param(
'{"error message": "has a message", "stack Trace": "has a stacktrace", "error Type": "has a type"}',
False,
Expand Down

0 comments on commit eaf6e86

Please sign in to comment.