Skip to content

Commit

Permalink
Lambda execute stack trace should be not formatted with extra space (#…
Browse files Browse the repository at this point in the history
…1615) (#1634)

[manual backport stable-5] Lambda execute stack trace should be not formatted with extra space 

…#1615)
Lambda execute stack trace should be not formatted with extra space
SUMMARY
Fixes #1497
ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
plugins/modules/lambda_execute.py
ADDITIONAL INFORMATION
Reviewed-by: Jill R
Reviewed-by: Bikouo Aubin
Reviewed-by: Alina Buzachis
Reviewed-by: Mike Graves [email protected]
(cherry picked from commit 271523e)
SUMMARY


ISSUE TYPE


Bugfix Pull Request
Docs Pull Request
Feature Pull Request
New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Mike Graves <[email protected]>
Reviewed-by: Helen Bailey <[email protected]>
  • Loading branch information
alinabuzachis authored Jun 30, 2023
1 parent 93e184e commit 1b87136
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/1615-no_formatted_with_extra_space.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- Fixes to the stack trace output, where it does not contain spaces between each character. The module had incorrectly always outputted extra spaces between each character. (https://github.com/ansible-collections/amazon.aws/pull/1615)
17 changes: 8 additions & 9 deletions plugins/modules/lambda_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,16 @@ def main():
[results['output'].get('stackTrace'), results['output'].get('errorMessage')]):
# AWS sends back stack traces and error messages when a function failed
# in a RequestResponse (synchronous) context.
template = ("Function executed, but there was an error in the Lambda function. "
"Message: {errmsg}, Type: {type}, Stack Trace: {trace}")
template = (
"Function executed, but there was an error in the Lambda function. "
"Message: {errmsg}, Type: {type}, Stack Trace: {trace}"
)

error_data = {
# format the stacktrace sent back as an array into a multiline string
'trace': '\n'.join(
[' '.join([
str(x) for x in line # cast line numbers to strings
]) for line in results.get('output', {}).get('stackTrace', [])]
),
'errmsg': results['output'].get('errorMessage'),
'type': results['output'].get('errorType')
"trace": "\n".join(results.get("output", {}).get("stackTrace", [])),
"errmsg": results["output"].get("errorMessage"),
"type": results["output"].get("errorType"),
}
module.fail_json(msg=template.format(**error_data), result=results)

Expand Down

0 comments on commit 1b87136

Please sign in to comment.