AC-038 Scenario not caught

Valid shape, wrong meaning

Behaviour a schema cannot see

How to run this card's commands yourself

1. The problem

In one sentence

The response has the right fields with the right types, and the values are wrong: the numbers do not add up, or the answer is about a different thing than the one you asked for.

A story

A client asks for order 1: 3 units at 10.00 each. The answer has unit_price: 10.00, quantity: 3 and total: 10.00. The total should be 30.00. The server copied the unit price into total. Every field is present and is a number, so the schema is satisfied. The invoice goes out for a third of its value.

A second case: a client asks for GET /products/5 and gets a product whose id is 1. The server always returns the first product.

Why it hurts

The shape of a response is the part that is easy to check. The meaning is where the money is. A schema cannot say that total equals unit_price × quantity, or that the id in the answer must be the id in the URL.

  • For developers: these bugs pass every schema check, so they live until a person reads the numbers. They usually come from a wrong field in a mapping, or a lookup that ignores its argument.
  • For managers: wrong amounts, wrong customers, wrong records. These are the bugs that reach invoices and reports, and are found by customers.
  • For DevOps: keep a small set of “golden” requests whose correct answer you know exactly, and assert on the values after every deploy.

Example

The broken servers from two failure-catalog demos:

GET /orders/1    ->  {"unit_price": 10.00, "quantity": 3, "total": 10.00 ...}    (total should be 30.00)
GET /products/5  ->  {"id": 1 ...}                                               (id should be 5)

How to detect it without clrsig

  • Pick a record you know and check the arithmetic yourself: curl -s URL/orders/1 | jq '.total == (.unit_price * .quantity)'.
  • Compare the id in the answer with the id you asked for.

How to fix it

There are two usual causes:

  1. The code is wrong (almost always). Fix the calculation or the lookup, and add a test for the business rule.
  2. The spec is silent. The rule (total = unit price × quantity) lives only in people’s heads. Write it in the description of the field, so it can be tested.

To tell which: ask the person who owns the rule. Never accept “the schema passes” as proof the answer is right.

AC-006 A field has the wrong type, AC-037 A filter, limit or sort parameter is ignored, AC-040 A business rule is broken though every response looks fine. See also the site’s Syntactically Valid but Semantically Invalid Payloads.

Words used on this page are explained once in the glossary.

2. How clrsig helps

Check

No built-in check, and the state is not caught. Every response matches its schema. A scenario with value assertions (jsonpath) says what the correct values are, and fails where the server is wrong.

Command

Each demo is a runnable server in the failure catalog, and its scenario only reads data (GET). From the demo folder, with Go installed:

cd failures/fm-022-01-semantically-invalid
go run broken/main.go &
clrsig run scenarios/detect.yaml --env environments/local.yaml

Exit code: 0 all steps pass, 1 a step failed, 2 the scenario or the setup is broken. Here it is 1. Against fixed/main.go both steps pass and the exit code is 0.

What you see

Output from clrsig v0.21.0, recorded on 2026-11-30. The arithmetic demo, fm-022-01-semantically-invalid:

Scenario: fm-022-01 — Syntactically Valid but Semantically Invalid Payloads

  FAIL  order 1: total must equal unit_price x quantity (3 x 10.00 = 30.00)  200  19ms
         ✗ jsonpath $.total eq 30: expected "30"; got "10"
  SKIP  order 2: total must equal unit_price x quantity (2 x 24.99 = 49.98)
         skipped: step 1 (order 1: total must equal unit_price x quantity (3 x 10.00 = 30.00)) failed and its failPolicy is stop; set failPolicy: continue to run the steps after a failure

FAILED  0 passed, 1 failed, 1 skipped  (0/1 assertions passed)  19ms

The identity demo, fm-022-09-id-mismatch:

Output from clrsig v0.21.0, recorded on 2026-11-30:

Scenario: fm-022-09 — Response ID Mismatch

  FAIL  GET /products/5 — response id must equal 5 (broken server always returns id=1)  200  12ms
         ✗ jsonpath $.id eq 5: expected "5"; got "1"

FAILED  0 passed, 1 failed, 0 skipped  (0/1 assertions passed)  12ms

How to read it: the expected value and the value the server gave. The scenario carries the rule in its label, so the next reader knows what was meant.

Where to look

  • Desktop app: open the scenario and run it; each step shows its assertion result.
  • Reports: --format json and junit on clrsig run.
  • GitHub Action: use command: run with the scenario and env inputs. The demos check with their own assertions. To compare your own responses with your spec, name it with specFile in the scenario, or give the spec input, which replaces it; older releases of the Action ignored that input with run (setup and upgrading).

How clrsig helps you fix it

It shows the value you expected and the value you got, for exactly the field that is wrong. It does not know your business rules: you write them as assertions.

Limits

  • It needs data whose correct answer you know, so a fixed test data set.
  • Only the rules you write are tested; a rule nobody wrote down is not checked.

More ways

Nothing yet.

3. Video brief for Google NotebookLM

VIDEO BRIEF — AC-038 · Valid shape, wrong meaning
Length: 5 to 7 minutes. Language: English. Audience: developers, with a line each for managers and DevOps.
One idea: a schema can say what a response looks like, not what it means; the money is in the meaning.
Open with this story: A client asks for an order of 3 units at 10.00 each. The answer has a unit price of 10.00, a quantity of 3 and a total of 10.00. The total should be 30.00. The server copied the unit price into the total. Every field is present and is a number, so the schema is satisfied. The invoice goes out for a third of its value.
Say these facts, in this order:
1. Demo one: the scenario expects a total of 30 for order 1 and gets 10.
2. Demo two: asking for product 5 returns a product with an id of 1; the server always returns the first product.
3. A schema cannot say that total equals unit price times quantity, or that the id in the answer must be the id in the URL.
4. A scenario with value assertions says what is correct and fails exactly where the server is wrong.
5. Two usual causes: the code is wrong (a wrong field in a mapping, a lookup that ignores its argument), or the rule lives only in people's heads and the spec is silent.
6. For managers: these are the bugs that reach invoices and reports and are found by customers.
7. For DevOps: keep a small set of golden requests with known answers and assert on the values after every deploy.
Show on screen: the two example lines, the commands (go run broken/main.go and clrsig run scenarios/detect.yaml --env environments/local.yaml), and the two output blocks, copied exactly from the card.
Name the check: none built in; found by value assertions in a scenario. Say the clrsig version: v0.21.0.
Explain these words once: assertion (a check you write that a response must satisfy); JSONPath (a short way to point at a field in a JSON body); scenario (a script of steps with your own checks); exit code (0 clean, 1 a finding, 2 setup or spec broken).
Say what clrsig does not see here: it does not know your business rules; it needs data whose correct answer you know; a rule nobody wrote down is not checked.
Safety line (if a write is shown): not needed, these scenarios only send GET requests.
Finish with three recap questions:
1. Why does the schema pass in demo one? (Every field is present and is a number.)
2. What must the id in the answer equal? (The id in the URL.)
3. What is a golden request? (A request whose correct answer you know exactly.)
Tease the next video: AC-039 · HTTP method semantics are broken.
Do not: say "contract testing" alone; say clrsig "catches everything"; invent flags, IDs or numbers; read tables aloud; use any fact that is not in the card.