Skip to content

Add error handling if lambda logs are not received from the environment #12521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,20 @@ def invoke(self, *, invocation: Invocation) -> InvocationResult:
)
# TODO: consider using the same prefix logging as in error case for execution environment.
# possibly as separate named logger.
LOG.debug("Got logs for invocation '%s'", invocation.request_id)
for log_line in invocation_result.logs.splitlines():
LOG.debug(
"[%s-%s] %s",
function_id.function_name,
if invocation_result.logs is not None:
LOG.debug("Got logs for invocation '%s'", invocation.request_id)
for log_line in invocation_result.logs.splitlines():
LOG.debug(
"[%s-%s] %s",
function_id.function_name,
invocation.request_id,
truncate(log_line, config.LAMBDA_TRUNCATE_STDOUT),
)
else:
LOG.warning(
"[%s] Error while printing logs for function '%s': Received no logs from environment.",
invocation.request_id,
truncate(log_line, config.LAMBDA_TRUNCATE_STDOUT),
function_id.function_name,
)
return invocation_result

Expand All @@ -260,7 +267,8 @@ def store_logs(
self.log_handler.add_logs(log_item)
else:
LOG.warning(
"Received no logs from invocation with id %s for lambda %s",
"Received no logs from invocation with id %s for lambda %s. Execution environment logs: \n%s",
invocation_result.request_id,
self.function_arn,
execution_env.get_prefixed_logs(),
Copy link
Member

Choose a reason for hiding this comment

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

Good idea to present actionable output 👍

Hopefully, not too long 🤞

)
Loading