Improved error messages about payload deserialization #905
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR makes errors about payload deserialization into a concrete event type more informative.
For example, my lambda had
LambdaEvent<ApiGatewayProxyRequest>
and was failing with the following error message:That error message makes perfect sense to the developer of the runtime. A runtime user is likely to be stumped.
The problem is a mismatch between the payload and the target type, but the error says
building error response for Lambda Runtime API
. What does that mean?I had to look up the runtime source to understand what's going on.
The proposed message is makes it clearer that the error happened before the handler was called, relates to the deserialization and suggests where to find more info (TRACE):
I also added a note about logging with TRACE to see the raw payload. It is a very useful feature that is worth mentioning. I accidentally stumbled across it while working on this PR.
Looks like the runtime uses TRACE and not DEBUG.
Changes made
🔏 By submitting this pull request
cargo +nightly fmt
.cargo clippy --fix
.