Question 1,226 of 724
DVA-C02 Troubleshooting and Optimization Practice Question
A company is using Amazon API Gateway to expose a REST API. The API is integrated with an AWS Lambda function. Lately, the API is returning 502 Bad Gateway errors. What is the MOST likely cause?
⚠ Common exam trap
Many candidates confuse 502 errors with throttling (429) or permission issues (403/500), but the 502 specifically points to a malformed or error response from the backend integration.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The Lambda function is returning an unhandled exception.
A 502 Bad Gateway error from API Gateway typically indicates that the backend integration (in this case, the Lambda function) returned an error response. When a Lambda function throws an unhandled exception, API Gateway receives a 200 OK with a function error payload, but it cannot parse the response into a valid HTTP response, resulting in a 502. This is distinct from throttling or permission issues, which produce different HTTP status codes.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The API Gateway request throttling limit has been exceeded.
Why it's wrong here
API Gateway implements throttling at various levels to protect backend services and ensure fair usage, preventing overload. When the configured rate limits or burst limits are exceeded by incoming requests, API Gateway explicitly rejects the excess requests. This rejection is communicated to the client with an HTTP 429 Too Many Requests status code, indicating that the client should slow down its request rate, rather than a 502 which implies a backend service issue.
- ✗
The API Gateway API key is invalid.
Why it's wrong here
API keys are utilized by API Gateway to control access to API methods and track usage, often in conjunction with usage plans. If a client provides an API key that is either missing, invalid, or not associated with the requested API method or stage, API Gateway will deny access. This access denial is correctly represented by an HTTP 403 Forbidden status code, signifying that the client is not authorized to access the resource due to invalid credentials.
- ✓
The Lambda function is returning an unhandled exception.
Why this is correct
API Gateway expects its integrated Lambda function to return a specific JSON response format, including status code, headers, and body, for successful processing and mapping. When a Lambda function encounters an unhandled exception, times out, or returns malformed output that does not conform to this expected structure, API Gateway cannot properly map this response to an HTTP response for the client. Consequently, API Gateway returns an HTTP 502 Bad Gateway error, indicating that it received an invalid response from the upstream Lambda service.
- ✗
The Lambda function's execution role does not allow API Gateway to invoke it.
Why it's wrong here
For API Gateway to successfully invoke a Lambda function, the Lambda function's resource-based policy must explicitly grant `lambda:InvokeFunction` permission to the API Gateway service principal. If this necessary permission is absent or incorrectly configured, API Gateway's attempt to execute the function will be explicitly denied by the Lambda service. This permission-based denial results in an HTTP 403 Forbidden error, as the request is understood but access is prohibited due to insufficient authorization.
Quick reference
Cloud Service Model Comparison
| Model | You Manage | Provider Manages | Examples |
|---|---|---|---|
| IaaS | OS, runtime, apps, data | Hardware, hypervisor, networking | EC2, Azure VMs, GCP Compute Engine |
| PaaS | Apps and data | OS, runtime, middleware, hardware | Elastic Beanstalk, Azure App Service |
| SaaS | Data and settings only | Everything else | Microsoft 365, Salesforce, Workday |
| FaaS / Serverless | Function code only | Infra, scaling, runtime | Lambda, Azure Functions, Cloud Run |
| CaaS | Containers and apps | Kubernetes, OS, hardware | EKS, AKS, GKE |
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jul 4, 2026
This DVA-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DVA-C02 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.