Bird
0
0

You have this server code snippet handling updates:

medium📝 Debug Q14 of 15
Rest API - HTTP Status Codes
You have this server code snippet handling updates:
if resource.version != client_version:
    return Response(status=409, body={"error": "Version mismatch"})
else:
    update_resource()

But clients report they get 409 even when no conflict exists. What is the likely bug?
AClients are sending wrong HTTP methods.
BThe update_resource() function is missing.
CThe server should return 404 instead of 409.
DThe server is not comparing versions correctly; types may differ causing mismatch.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze version comparison logic

    If types differ (e.g., string vs int), equality check fails causing false conflicts.
  2. Step 2: Identify likely cause of false 409

    Incorrect type comparison leads to always triggering 409 even if versions match logically.
  3. Final Answer:

    The server is not comparing versions correctly; types may differ causing mismatch. -> Option D
  4. Quick Check:

    Type mismatch in version check causes false 409 [OK]
Quick Trick: Check data types when comparing versions to avoid false conflicts [OK]
Common Mistakes:
MISTAKES
  • Assuming missing update function causes 409
  • Confusing 409 with 404 errors
  • Blaming client HTTP methods without evidence

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes