1. The problem
In one sentence
The server labels the body with a Content-Type that the spec does not declare for that response, for example text/plain instead of application/json.
A story
A client calls GET /cases/resp-002-wrong-content-type. The spec says the answer is application/json. A proxy in front of the server, or a framework error handler, sends the body as text/plain; charset=utf-8. The body is correct JSON: {"id": 1, "name": "Alpha", "price": 9.99}. A strict client that picks its parser from the Content-Type refuses to read it as JSON.
Why it hurts
Many HTTP libraries choose how to read a body from its Content-Type. A wrong label makes them return a string, or throw. Often the label is wrong only for error pages from a proxy or a framework, so it appears in production and not in tests.
- For developers: the failure is in the layer between the code and the wire (proxy, middleware, error handler). Look there first, not in the handler.
- For managers: an integration that “worked in testing” fails for some responses in production. The cause is hard to find because the body looks fine to a human.
- For DevOps: check the response through the same path clients use (gateway, CDN, proxy), not only the app container. A header that the proxy rewrites is only visible there.
Example
The spec fragment:
responses:
"200":
description: A widget
content:
application/json:
schema:
$ref: "#/components/schemas/Widget"
The response:
HTTP/1.1 200 OK
content-type: text/plain; charset=utf-8
{"id": 1, "name": "Alpha", "price": 9.99}
The spec promises application/json. The server says text/plain.
How to detect it without clrsig
curl -i URLand read thecontent-typeline.curl -s -o /dev/null -w '%{content_type}\n' URLprints only the type.
How to fix it
There are two usual causes:
- The server or a layer in front of it is wrong (more likely). Set
Content-Type: application/jsonon that response, or find the layer that replaces it. - The spec is wrong. The operation really returns text. Then declare
text/plainfor this response in the spec.
To tell which: look at what clients are reading today. If they expect JSON, fix the server. Never silence the check.
Related problems
AC-001 Status the spec never listed, AC-010 Body is not valid JSON, or is empty, AC-016 Malformed JSON that parsers read differently.
Words used on this page are explained once in the glossary.
2. How clrsig helps
Check
CS-RESP-002 Wrong response Content-Type. State: caught. Severity today: failure (exit code 1).
Command
--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-002-wrong-content-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-002-wrong-content-type
FAIL GET /cases/resp-002-wrong-content-type 200 15ms
✗ GET /cases/resp-002-wrong-content-type 200 answered with Content-Type "text/plain", but the spec declares application/json for this response; the body was not checked
→ [CS-RESP-002] Content-Type is "text/plain", the spec says application/json. Why: The spec declares the 200 response body as application/json, but the server labelled it "text/plain", so the body was not compared with the schema: nothing about its fields was checked. Where: response header "Content-Type" (spec: GET /cases/resp-002-wrong-content-type → response 200 → content). Fix: Make the server send Content-Type application/json, or declare "text/plain" for response 200 in the spec.
FAILED 37 operations · 0 passed · 1 failed · 36 skipped 17ms
How to read it: the finding names the type the server sent and the type the spec declares. It also says “the body was not checked”. Fix the type, then run again to see any problems in the body.
Where to look
- Desktop app: Check Conformance shows the failure under “wrong content type”. Help, What We Check lists
CS-RESP-002. - Reports: with
--format json, the finding carries"checkId": "CS-RESP-002". - GitHub Action: it runs the same command.
How clrsig helps you fix it
It gives both types and the place in the spec, and offers the two fixes. It cannot see which layer changed the header.
Limits
- When the type is wrong, the body is not compared at all. A second problem inside the body stays hidden until you fix this one.
- The
schemaassertion in a scenario does not look at theContent-Type; it reads the body as JSON whatever the type. - Parameters such as
charsetare ignored when types are compared.
More ways
Nothing yet.