AC-008 Contract caught CS-RESP-007

A date-time is in the wrong format

The response does not match the contract

How to run this card's commands yourself

1. The problem

In one sentence

A field the spec declares as format: date-time holds text that is not a valid date and time, for example yesterday.

A story

The spec says createdAt is an ISO 8601 date-time, like 2026-11-22T10:30:00Z. A report endpoint sends "createdAt": "yesterday" for rows that have no exact time. A client that sorts by date fails to parse it, and a Swift client crashes while decoding the list.

Why it hurts

Dates are the most common source of silent mistakes: other formats, local time with no zone, a missing T, a Unix number. Every client parses dates with a library that expects one exact format.

  • For developers: one bad row in a list can break the parsing of the whole list.
  • For managers: reports and audit trails show wrong or missing times, and time-based rules (expiry, billing dates) misfire.
  • For DevOps: keep time zones explicit (Z or an offset) in every environment, and check dates in your pipeline: a server with a different locale can change the format.

Example

The spec fragment:

TimestampDoc:
  type: object
  required: [createdAt]
  properties:
    createdAt: { type: string, format: date-time }

The response from GET /contract-fail/cases/resp-007e-bad-datetime:

{"createdAt": "yesterday"}

How to detect it without clrsig

  • curl -s URL | jq -r .createdAt | xargs -I{} date -d {} fails for a bad value (with GNU date).
  • In a review, ask: “which formatter writes this date, and what does it write when the value is missing or has no zone?”

How to fix it

There are two usual causes:

  1. The code is wrong (more likely). It writes a local or free-text date. Use one formatter that always writes an ISO 8601 date-time with a zone.
  2. The spec is wrong. The field really holds free text. Then declare it as type: string without the format.

To tell which: look at what clients do with the value. If they parse it as a date, the code is wrong. Never silence the check.

AC-007 A value breaks a rule in the schema, AC-006 A field has the wrong type, AC-009 Null where null is not allowed. Failure-catalog demo: FM-001-02 (a date/time format failure). 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-007 Value outside the declared constraints, here the date-time format. 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-007e-bad-datetime --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-007e-bad-datetime

  FAIL  GET     /cases/resp-007e-bad-datetime  200  17ms
         ✗ Error at "/createdAt": string doesn't match the format "date-time": string doesn't match pattern "^[0-9]{4}-(0[1-9]|10|11|12)-(0[1-9]|[12][0-9]|3[01])T([0-1][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)([0-1][0-9]|2[0-3]):[0-5][0-9])$"
         → [CS-RESP-007] "createdAt" is an RFC 3339 date-time (for example 2026-11-22T10:00:00Z). Why: The schema sets a rule for createdAt: it is an RFC 3339 date-time (for example 2026-11-22T10:00:00Z). Where: response body, field createdAt (spec: GET /cases/resp-007e-bad-datetime → response 200 → body schema). Fix: Send a value in the date-time format, or change the field's format in the spec if the server is right.

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

How to read it: the → line says what the field must be (an RFC 3339 date-time, with an example). The long pattern in the ✗ line is the exact shape: year, month, day, a T, time, then Z or an offset such as +01:00.

Where to look

  • Desktop app: Check Conformance lists the failure with the field. 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.

How clrsig helps you fix it

It names the field, gives a short example of a valid date-time, and shows the pattern. The message does not print the bad value; look at the response (curl) to see it.

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-008 · A date-time is in the wrong format
Length: 5 to 7 minutes. Language: English. Audience: developers, with a line each for managers and DevOps.
One idea: dates are promises too: if the spec says date-time, every value must be an ISO 8601 date and time with a zone.
Open with this story: The spec says createdAt is an ISO 8601 date-time. A report endpoint sends the word yesterday for rows without an exact time. A client that sorts by date fails to parse it, and a Swift client crashes while decoding the list.
Say these facts, in this order:
1. The spec declares createdAt with format date-time. The server sent the text yesterday.
2. Clients parse dates with a library that expects one exact format; one bad row can break a whole list.
3. Common causes: other formats, local time with no zone, a missing T, free text.
4. Two usual causes: the code writes a local or free-text date (more likely), or the spec is wrong because the field really holds free text.
5. For managers: reports and time-based rules such as expiry misfire.
6. For DevOps: keep time zones explicit in every environment.
Show on screen: the TimestampDoc schema, the response {"createdAt": "yesterday"}, the command (clrsig conform specs/contract-fail.yaml -b http://localhost:8080/contract-fail --env clrsig/environments/contract-fail.yaml --paths /cases/resp-007e-bad-datetime --explain), and the first line of the output block that names the field, 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: ISO 8601 (the standard way to write a date and time, such as 2026-11-22T10:30:00Z); format (an extra rule on a string in the spec); exit code (0 clean, 1 a finding, 2 setup or spec broken).
Say what clrsig does not see here: the supported formats are date, date-time, email, uuid, ipv4, ipv6, byte, uri and hostname; others such as duration pass without a check.
Safety line (if a write is shown): not needed, this command sends one GET.
Finish with three recap questions:
1. What does a valid date-time need? (A date, a T, a time and a zone, such as Z.)
2. Name a format clrsig does not validate. (For example duration or uri-reference.)
3. Name one usual cause. (The code writes a local or free-text date.)
Tease the next video: AC-009 · Null where null is not allowed.
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.