Bird
0
0

Given this snippet of server-side pseudocode handling API requests:

medium📝 Debug Q14 of 15
Rest API - HTTP Status Codes

Given this snippet of server-side pseudocode handling API requests:

if request_count > limit:
    return 429, {"Retry-After": "30"}, "Too many requests"
else:
    process_request()

What is a likely bug if clients keep getting 429 responses even after waiting 30 seconds?

AThe server is processing requests without any limit.
BThe <code>Retry-After</code> header is missing from the response.
CThe server is not checking <code>request_count</code> at all.
DThe server does not reset <code>request_count</code> after the wait period.
Step-by-Step Solution
Solution:
  1. Step 1: Understand rate limiting logic

    The server limits requests by counting them and returning 429 if over limit.
  2. Step 2: Identify why 429 repeats after wait

    If request_count never resets, the server always thinks limit is exceeded.
  3. Step 3: Confirm bug cause

    Not resetting request_count after wait causes repeated 429 responses.
  4. Final Answer:

    The server does not reset request_count after the wait period. -> Option D
  5. Quick Check:

    Persistent 429 means counter not reset [OK]
Quick Trick: Reset request count after wait to avoid repeated 429 [OK]
Common Mistakes:
  • Ignoring the need to reset counters
  • Assuming Retry-After header alone fixes issue
  • Thinking server ignores request limits

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes