AC-004 Contract caught CS-RESP-004

A response header has a value of the wrong type

The response does not match the contract

How to run this card's commands yourself

1. The problem

In one sentence

A response header is sent, but its value does not fit the type the spec gives it, for example many where an integer is declared.

A story

The spec says X-Total-Count is an integer. A developer replaces the real count with a friendly word while the count is being computed, and the server sends X-Total-Count: many. The client reads the header, tries to parse a number, and either throws or gets NaN.

Why it hurts

A client that trusts the spec parses the header as the declared type. A wrong value fails at parse time, often far from the place the header was set, and it often fails only for some responses.

  • For developers: header values are strings on the wire, so nothing in the code complains. Only the reader finds out.
  • For managers: features that depend on headers (paging, limits, caching) break for some users, with no visible server error.
  • For DevOps: the same header can differ between the app and a proxy. Check through the path clients use.

Example

The spec fragment:

headers:
  X-Total-Count:
    required: true
    schema: { type: integer, minimum: 0 }

The response:

HTTP/1.1 200 OK
x-total-count: many
content-type: application/json

{"id": 1, "name": "Alpha", "price": 9.99}

The header is present, but many is not an integer.

How to detect it without clrsig

  • curl -sI URL | grep -i x-total-count and check the value by eye.
  • In a review, ask: “where is this header value built, and can it ever be empty, text, or a negative number?”

How to fix it

There are two usual causes:

  1. The code is wrong (more likely). The value is built from something that is not always a number. Send a value of the declared type on every path.
  2. The spec is wrong. The header really carries text. Then correct its schema in the spec.

To tell which: ask what clients parse today. Never silence the check.

AC-003 A required response header is missing, AC-006 A field has the wrong type, AC-005 A required field is missing from the body.

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

2. How clrsig helps

Check

CS-RESP-004 Response header of the wrong type. State: caught. Severity today: failure (exit code 1). It applies to declared headers, required or optional.

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-004-wrong-header-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-004-wrong-header-type

  FAIL  GET     /cases/resp-004-wrong-header-type  200  16ms
         ✗ GET /cases/resp-004-wrong-header-type 200: the response header "X-Total-Count" has a value that does not fit the spec: value many: an invalid integer: invalid syntax
         → [CS-RESP-004] The header "X-Total-Count" has a value that does not fit the spec. Why: The spec gives the "X-Total-Count" header of response 200 a type, and the value the server sent is not valid for it. The body was not compared with the schema. Where: response header "X-Total-Count" (spec: GET /cases/resp-004-wrong-header-type → response 200 → headers → X-Total-Count). Fix: Send a value of the declared type in "X-Total-Count", or correct the header's schema in the spec.

FAILED  37 operations  ·  0 passed  ·  1 failed  ·  36 skipped  17ms

How to read it: the header, the value that was sent (many), and why it does not fit (an invalid integer).

Where to look

  • Desktop app: Check Conformance lists the failure with the same explanation. Help, What We Check lists CS-RESP-004.
  • Reports: with --format json, the finding carries "checkId": "CS-RESP-004".
  • GitHub Action: it runs the same command.

How clrsig helps you fix it

It shows the exact value and the type the spec wants. It cannot tell you where in the code the value was built.

Limits

  • The body is not compared when a header problem is found; fix it and run again.
  • A header that the spec does not mention is never checked (CS-GAP-003).
  • The schema assertion in a scenario ignores headers.

More ways

Nothing yet.

3. Video