AC-012 Contract partly CS-RESP-010

An extra field in a closed schema

The response does not match the contract

How to run this card's commands yourself

1. The problem

In one sentence

The response has a field the schema does not know, and the schema is “closed”, which means it says no other fields are allowed.

A story

The spec says the answer is {"id": 1} and nothing else (additionalProperties: false). A developer adds a helper field while debugging, "extra": true, and forgets to take it out. A client that validates strictly against the spec, such as a generated SDK in strict mode, rejects the whole response.

Why it hurts

The extra field may be harmless, or it may be internal data that should not leave the server. A closed schema is the owner’s way to say “this is everything”.

  • For developers: the cause is usually debug code, or an object that is serialised whole instead of through a response model.
  • For managers: internal data (cost, flags, internal IDs) can leave the system without anyone deciding it should. This is a data-exposure risk, not just a style problem.
  • For DevOps: a closed schema makes this check strict. If the schema is open, extra fields are legal and nothing is reported (see Limits).

Example

The spec fragment (ClosedDoc):

ClosedDoc:
  type: object
  additionalProperties: false
  required: [id]
  properties:
    id: { type: integer }

The response from GET /contract-fail/cases/resp-010-extra-property-closed:

{"id": 1, "extra": true}

A contrast fixture, resp-010b-extra-property-open, sends {"id": 1, "name": "Alpha", "price": 9.99, "extra": true} for a schema that does not set additionalProperties: false. OpenAPI allows extra fields by default, so it is legal and clrsig passes it.

How to detect it without clrsig

  • curl -s URL | jq 'keys' and compare with the properties in the spec.
  • In a review, ask: “is the response built from a model with a fixed list of fields, or from the raw object?”

How to fix it

There are two usual causes:

  1. The code is wrong (more likely). Remove the field, and build the response from a model that lists exactly the fields to send.
  2. The spec is wrong. The field is meant. Declare it in the schema.

To tell which: ask whether any client should see the field. Never silence the check.

AC-013 A secret field appears in a response, AC-011 A body that can have several shapes fits none of them, AC-015 Fields renamed, removed or re-cased. Failure-catalog demo: FM-044-01 (sensitive data in a response, caught by a closed schema). See also the site’s Sensitive Data Exposure in API Responses.

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

2. How clrsig helps

Check

CS-RESP-010 Undeclared extra property. State: partly. clrsig reports it only when the schema sets additionalProperties: false. 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-010-extra-property-closed --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-010-extra-property-closed

  FAIL  GET     /cases/resp-010-extra-property-closed  200  14ms
         ✗ property "extra" is unsupported
Value:
  {…}
         → [CS-RESP-010] "extra" is not allowed in the response. Why: The schema forbids properties it does not declare (additionalProperties: false) and the response has "extra". Where: response body, field extra (spec: GET /cases/resp-010-extra-property-closed → response 200 → body schema). Fix: Stop sending "extra", or declare it in the schema.

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

How to read it: the field is extra, and the reason is additionalProperties: false in the schema. {…} stands for the object: clrsig does not print it.

For the open schema (--paths /cases/resp-010b-extra-property-open), the same run ends with PASSED and exit code 0.

Where to look

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

How clrsig helps you fix it

It names the field and the rule, and says to stop sending it or to declare it. It cannot tell you whether the field is sensitive.

Limits

  • On an open schema (the default in OpenAPI), extra fields are legal and are not reported (CS-GAP-002). If you want strictness, close the schema in the spec.
  • 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-012 · An extra field in a closed schema
Length: 5 to 7 minutes. Language: English. Audience: developers, with a line each for managers and DevOps.
One idea: a closed schema says "this is everything"; an extra field may be harmless, or it may be data that should never leave the server.
Open with this story: The spec says the answer is a body with an id and nothing else. A developer adds a helper field while debugging, extra: true, and forgets to take it out. A client that validates strictly against the spec rejects the whole response.
Say these facts, in this order:
1. The schema sets additionalProperties to false. The server sent a field called extra.
2. OpenAPI allows extra fields by default. clrsig reports them only when the schema is closed.
3. The contrast: an extra field in a schema that does not close it is legal, and that run passes with exit code 0.
4. To find it without clrsig: list the keys of the body with curl and jq and compare them with the properties in the spec.
5. In the output, the line with the cross says the property extra is unsupported. Under Value, the three dots in braces stand for the object: clrsig does not print it. The line with the arrow gives the check ID, why it fails, where it is, and says to stop sending the field or declare it.
6. Two usual causes: the code adds a field by mistake, for example by serialising a whole object instead of a response model (more likely), or the spec is wrong and the field is meant.
7. To tell which: ask whether any client should see the field. Never silence the check.
8. For managers: internal data can leave the system without anyone deciding it should. This is a data-exposure risk.
9. For DevOps: if you want this check to be strict, close the schema in the spec.
Show on screen: the ClosedDoc schema; the response {"id": 1, "extra": true}; the command (clrsig conform specs/contract-fail.yaml -b http://localhost:8080/contract-fail --env clrsig/environments/contract-fail.yaml --paths /cases/resp-010-extra-property-closed --explain); and the output block, copied exactly from the card.
Name the check: CS-RESP-010, Undeclared extra property; its state is partly caught. Say the clrsig version: v0.21.0.
Explain these words once: closed schema (a schema that forbids fields it does not list); open schema (extra fields are allowed); response model (a fixed list of fields a response is built from); exit code (0 clean, 1 a finding, 2 the setup or the spec is broken).
Say what clrsig does not see here: on an open schema, extra fields are not reported; it cannot tell whether a field is sensitive; 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. When does clrsig report an extra field? (Only when the schema sets additionalProperties to false.)
2. Why is an extra field a risk for managers? (Internal data may leave the system.)
3. How do you make the check strict? (Close the schema in the spec.)
Tease the next video: AC-013 · A secret field appears in a response.
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.