From 91a3edc82fb218c569dd0d19871267c08235b523 Mon Sep 17 00:00:00 2001 From: rimutaka Date: Wed, 3 Jul 2024 22:26:47 +1200 Subject: [PATCH] Improved payload Deser error messages * made error messages more informative * added a suggestion to log at TRACE level to README --- README.md | 4 +++- lambda-runtime/src/layers/api_response.rs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0a19e467..44ec1983 100644 --- a/README.md +++ b/README.md @@ -306,7 +306,9 @@ async fn main() -> Result<(), Error> { } ``` -The subscriber uses `RUST_LOG` as the environment variable to determine the log level for your function. It also uses [Lambda's advance logging controls](https://aws.amazon.com/blogs/compute/introducing-advanced-logging-controls-for-aws-lambda-functions/) if they're configured for your function. By default, the log level to emit events is `INFO`. +The subscriber uses `RUST_LOG` environment variable to determine the log level for your function. It also uses [Lambda's advanced logging controls](https://aws.amazon.com/blogs/compute/introducing-advanced-logging-controls-for-aws-lambda-functions/), if configured. + +By default, the log level to emit events is `INFO`. Log at `TRACE` level for more detail, including a dump of the raw payload. ## AWS event objects diff --git a/lambda-runtime/src/layers/api_response.rs b/lambda-runtime/src/layers/api_response.rs index 5994012c..7c963f68 100644 --- a/lambda-runtime/src/layers/api_response.rs +++ b/lambda-runtime/src/layers/api_response.rs @@ -98,7 +98,7 @@ where Ok(()) }; if let Err(err) = trace_fn() { - error!(error = ?err, "failed to parse raw JSON event received from Lambda"); + error!(error = ?err, "Failed to parse raw JSON event received from Lambda. The handler will not be called. Log at TRACE level to see the payload."); return RuntimeApiResponseFuture::Ready(Some(Err(err))); }; @@ -124,7 +124,7 @@ fn build_event_error_request<'a, T>(request_id: &'a str, err: T) -> Result> + Debug, { - error!(error = ?err, "building error response for Lambda Runtime API"); + error!(error = ?err, "Request payload deserialization into LambdaEvent failed. The handler will not be called. Log at TRACE level to see the payload."); EventErrorRequest::new(request_id, err).into_req() }