Skill 4.1.1

Debug application code and service integration issues to identify defects.

Key Concepts

Locally, the AWS SAM CLI can run functions with a debugger attached (sam local invoke -d 5858) so you can step through code in your IDE, and the AWS Toolkits for VS Code and JetBrains add Lambda debugging and AWS resource browsing.

In AWS, start with the error message and stack trace in CloudWatch Logs, then reproduce the problem with the same input event. Common defects include unhandled exceptions, missing environment variables, wrong data types and code that assumes state survives between invocations. AI tools such as Kiro can explain an error and propose a fix, as described in skill 4.1.5.

Common causes include missing IAM permissions (on the execution role or the target's resource policy), KMS key policies that do not allow a service to use the key, timeouts (API Gateway's 29-second integration limit or a Lambda timeout shorter than the work), throttling and quota limits, VPC networking (no route to an AWS endpoint), and payloads in an unexpected format, such as a non-proxy integration response.

X-Ray traces show which integration failed, CloudTrail shows denied API calls with the exact action, and aws sts decode-authorization-message decodes encoded authorization errors. API Gateway execution logs show the request sent to and the response received from the backend.