AC-007 Contract caught CS-RESP-007

A value breaks a rule in the schema

The response does not match the contract

How to run this card's commands yourself

1. The problem

In one sentence

A value has the right type but breaks a rule the schema sets: it is not in the allowed list (enum), is below a minimum, is too long, or does not match a pattern.

A story

The spec says an account status is active or inactive. A new feature adds archiving, and the server starts answering {"status": "archived"}. The spec was not updated. The client has a switch with two cases. For archived it falls to the default branch and treats the account as inactive, then bills it again.

Why it hurts

Rules are what let a client be simple. A client that knows the status is one of two values does not write code for a third. A value outside the rule moves the problem from the server to every client.

  • For developers: new values appear when a feature is added, and the spec is not touched. Clients with strict enum types fail to read the body at all.
  • For managers: business decisions (billing, access, shipping) are made on wrong states. These errors are quiet and expensive to undo.
  • For DevOps: this is stable and testable: fail the build when a value leaves its rule, and make adding a value to the spec part of the same change.

Example

The spec fragment:

StatusDoc:
  type: object
  required: [status]
  properties:
    status: { type: string, enum: [active, inactive] }

The response from GET /contract-fail/cases/resp-007-enum:

{"status": "archived"}

A second fixture, resp-007b-minimum, shows a number below its minimum: the spec says quantity is an integer of at least 0, and the server sends {"quantity": -1}.

How to detect it without clrsig

  • curl -s URL | jq .status and compare with the allowed list.
  • In a review, search the code for places that add a new status, and ask whether the spec has the same value.

How to fix it

There are two usual causes:

  1. The spec is out of date (more likely for an enum). A feature added a legal value. Add it to the spec, and tell clients before shipping, because it can break strict ones.
  2. The code is wrong. It produces a value that should never exist (-1, an empty string). Fix the code.

To tell which: ask whether the value is meant. Never silence the check.

AC-006 A field has the wrong type, AC-008 A date-time in the wrong format, AC-009 Null where null is not allowed. Failure-catalog demos: FM-010-07 (a minimum value violated) and FM-022-03 (an enum violation).

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

2. How clrsig helps

Check

CS-RESP-007 Value outside the declared constraints. State: caught. Severity today: failure (exit code 1). It covers enum, minimum, maximum, minLength, maxLength, pattern, minItems, uniqueItems, the date-time format, and null where nullable is not set. It is also caught by the schema assertion.

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-007-enum --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-007-enum

  FAIL  GET     /cases/resp-007-enum  200  14ms
         ✗ Error at "/status": value is not one of the allowed values ["active","inactive"]
Value:
  "archived"
         → [CS-RESP-007] "status" is one of ["active","inactive"]. Why: The schema sets a rule for status: it is one of ["active","inactive"]. The server sent "archived". Where: response body, field status (spec: GET /cases/resp-007-enum → response 200 → body schema). Fix: Send one of the allowed values, or add the value to the enum in the spec if the server is right.

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

How to read it: the field (status), the rule it breaks (the allowed values) and the value that was sent ("archived"). The output prints that one value, not the schema or the response body.

For the minimum fixture, the same command with --paths /cases/resp-007b-minimum gives number must be at least 0 for quantity with the value -1.

Where to look

  • Desktop app: Check Conformance lists the failure with the field and the rule. Help, What We Check lists CS-RESP-007.
  • Reports: with --format json, the finding carries "checkId": "CS-RESP-007".
  • GitHub Action: it runs the same command.
  • Scenario: a schema assertion reports the same problem.

How clrsig helps you fix it

It names the field, the rule and the value. The why line names the rule and the value that was sent. It cannot tell you whether the rule or the value is the intended one.

Limits

  • Formats outside date, date-time, email, uuid, ipv4, ipv6, byte, uri and hostname (for example uri-reference or duration) are not validated (CS-GAP-001).
  • With an OpenAPI 3.0 spec, as here, only the first problem in a response body is reported. With 3.1, each problem has its own line.

More ways

Nothing yet.

3. Video brief for Google NotebookLM

VIDEO BRIEF — AC-007 · A value breaks a rule in the schema
Length: 5 to 7 minutes. Language: English. Audience: developers, with a line each for managers and DevOps.
One idea: a value can have the right type and still break a rule the schema sets, and rules are what let clients stay simple.
Open with this story: The spec says an account status is active or inactive. A new feature adds archiving and the server starts answering archived. The spec is not updated. The client has two cases; archived falls to the default branch, the account is treated as inactive, and it is billed again.
Say these facts, in this order:
1. The schema allows two values for status. The server sent a third, archived.
2. The same check covers enum, minimum, maximum, minimum and maximum length, pattern, a minimum number of items, unique items, the date-time format, and null where it is not allowed.
3. A second example: the spec says quantity is at least 0; the server sent -1.
4. To find it without clrsig: print the field with curl and jq and compare it with the allowed list, or search the code for places that add a new status.
5. In the output, the line with the cross names the field and the rule. Under Value is the one value that broke it. The line with the arrow gives the check ID, why it fails, where it is in the spec, and how to fix it. The output prints that one value, not the schema or the response body.
6. Two usual causes: the spec is out of date after a new feature (more likely for an enum), or the code produces a value that should never exist.
7. To tell which: ask whether the value is meant. If it is, add it to the spec and tell clients before shipping, because a new value can break strict ones. Never silence the check.
8. For managers: decisions such as billing or access are made on wrong states; these errors are quiet and expensive to undo.
9. For DevOps: make adding a value to the spec part of the same change, and fail the build when a value leaves its rule.
10. In a scenario, a schema assertion reports the same problem.
Show on screen: the StatusDoc schema; the response {"status": "archived"}; the command (clrsig conform specs/contract-fail.yaml -b http://localhost:8080/contract-fail --env clrsig/environments/contract-fail.yaml --paths /cases/resp-007-enum --explain); and the output block, copied exactly from the card.
Name the check: CS-RESP-007, Value outside the declared constraints. Say the clrsig version: v0.21.0.
Explain these words once: enum (a fixed list of allowed values); constraint (a rule in the schema such as a minimum); exit code (0 clean, 1 a finding, 2 the setup or the spec is broken).
Say what clrsig does not see here: some formats are not validated, for example uri-reference and duration; the formats it does validate are date, date-time, email, uuid, ipv4, ipv6, byte, uri and hostname. With an OpenAPI 3.0 spec, as here, only the first problem in a response body is reported.
Safety line (if a write is shown): not needed, this command sends one GET.
Finish with three recap questions:
1. Which values did the spec allow and which did the server send? (active and inactive; archived.)
2. Name one more rule this check covers. (Minimum, maximum, length, pattern, and others.)
3. Who must be told when a value is added to an enum? (The clients, before shipping.)
Tease the next video: AC-008 · A date-time in the wrong format.
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.