QuizzifyTech

Bug library › API testing

API testing · Cart API

Cart API accepts quantity -3 and makes the total negative

P1 · CriticalExperiencedCart API

Want to find it yourself first? This page gives away the answer. Play this bug on a fake app screen and see if you can spot it in three tries.

Spot this bug

The clue

What should the server do with this request body?

Steps to reproduce

  1. Send POST /api/cart/items with "qty": -3
  2. Read the cart total

Expected result

400 Bad Request: quantity must be 1 or more

Actual result

200 OK with "total": -3897

Why it matters

This is a critical (P1) bug. It can lose money, expose private data or stop people from finishing a key task. A bug like this should block a release and be fixed straight away.

Testing tip

The screen may block negative numbers, but the API must too. Call APIs directly with values the UI never sends.

How to find bugs like this

API bugs live in the JSON between the app and the server: wrong records returned, fields that leak private data, bad status codes and limits that are not enforced. When you test, try these checks:

  • Read the whole response body, not only the status code.
  • Ask for other users’ records on purpose.
  • Look for fields that should never leave the server.
  • Send values at and past every limit.

More API testing bugs

See all 158 bugs