1. The problem
In one sentence
The response has a field of a different type than the spec declares, for example text where the spec says number.
A story
A shop app calls GET /widgets/1. The spec says the answer has a price that is a number. The server was changed to read prices from a database column that returns text, so it now answers "price": "9.99", with quotes. Every field is present and the status is 200, so nothing looks wrong in a quick test. The app adds price + tax and prints 9.990.80.
Why it hurts
Clients are written from the spec. A typed client (Java, Go, Swift, TypeScript with generated types) fails to read the body, or reads it wrongly. A loosely typed client (JavaScript, Python) keeps working and then computes wrong results, which is worse: nobody gets an error.
- For developers: the break is far from the cause. The crash or wrong total appears in the code that uses the value, not where the server sent it. Money fields as text are the classic case.
- For managers: wrong numbers shown to customers or stored downstream, with no error to alert anyone. These bugs are found late, often by a customer, and then need a data clean-up as well as a fix.
- For DevOps: this is a good gate for the pipeline: it is deterministic and it fails with a precise message. Run the check against a test environment after each deploy and fail the build on exit code
1.
Example
The spec fragment (Widget schema):
Widget:
type: object
required: [id, name, price]
properties:
id: { type: integer }
name: { type: string }
price: { type: number }
The response from GET /contract-fail/cases/resp-006-wrong-field-type:
{"id": 1, "name": "Alpha", "price": "9.99"}
They disagree on one field: the spec says price is a number, the server sent the string "9.99".
How to detect it without clrsig
curl -s URL | jq '.price | type'prints"string"where you expect"number".- In a review, ask: “which database or serialiser type produces this field, and does it write quotes?” Decimal and big-number types are the usual cause.
How to fix it
There are two usual causes. Find out which one is yours:
- The code is wrong (more likely). A serialiser writes a decimal as text. Fix the code so the JSON has a number. Check how it is converted, not just this one field.
- The spec is wrong. The text is intended (for example, to keep exact decimal digits). Then change the spec to
type: stringand tell clients. This is a change to the contract, so treat it like any other breaking change.
To tell which: ask the clients what they parse today. If they all read a number, the code is wrong. Never turn the check off to make the run green.
Related problems
AC-005 Required field missing, AC-007 Value breaks a schema rule, AC-009 Null where null is not allowed. Runnable demos in the failure catalog: FM-001-01, FM-010-04, FM-010-05, FM-010-06. See also the site’s Currency, Number, and Precision Formatting Failures.
Words used on this page are explained once in the glossary.
2. How clrsig helps
Check
CS-RESP-006 Body field of the wrong type. State: caught. Severity today: failure (exit code 1).
Command
The smallest command that shows it. --paths limits the run to this one GET, so nothing is written:
clrsig conform specs/contract-fail.yaml \
-b http://localhost:8080/contract-fail \
--env clrsig/environments/contract-fail.yaml \
--paths /cases/resp-006-wrong-field-type --explain
Exit code: 0 clean, 1 a finding, 2 the spec or the setup is broken. Here it is 1.
What you see
Output from clrsig v0.21.0, recorded on 2026-11-30. The lines for the 36 operations that --paths skipped are left out by grep -v '^ SKIP'; no line is edited.
contract-fail API 1.0.0
Base URL: http://localhost:8080/contract-fail
Limited by --paths /cases/resp-006-wrong-field-type
FAIL GET /cases/resp-006-wrong-field-type 200 20ms
✗ Error at "/price": value must be a number
Value:
"9.99"
→ [CS-RESP-006] "price" is text, the spec says number. Why: The server sent text ("9.99") where the spec declares a number. Where: response body, field price (spec: GET /cases/resp-006-wrong-field-type → response 200 → body schema). Fix: Send a number from the server (for example without quotes for a number), or change the type in the spec if the server is right.
FAILED 37 operations · 0 passed · 1 failed · 36 skipped 22ms
How to read it: FAIL is one operation. The ✗ line is the raw validator message with the path to the bad value (/price). The → line is clrsig’s explanation: the check ID, what is wrong, why, where, and how to fix it.
Where to look
- Desktop app: the Check Conformance page lists the same failure and groups failures by reason (for example “wrong type”). Help, What We Check lists
CS-RESP-006. - Reports: with
--format json, each finding has"kind": "wrong-type"and"checkId": "CS-RESP-006", pluswhere,expected,got,whyandfix. The JUnit, HTML and Markdown reports show the same text. - GitHub Action: it runs the same command; its
explain,formatandpathsinputs correspond to the flags above. - In a scenario: every step that has a spec runs this check automatically. A
schemaassertion runs a narrower version of it that looks at the body only.
How clrsig helps you fix it
It names the field (price), the type it found (text) and the type the spec wants (number), and says the fix can be on either side. It cannot tell you which side is right: that depends on what your clients read today.
Limits
- Only the first problem in a response is reported (
CS-GAP-011). Fix it and run again. - It compares what the server sent with the spec. It does not know whether
9.99is the right price. - If the
Content-Typeis wrong, the body is not compared at all (AC-002).
More ways
Nothing yet.