AC-051 Scenario caught CS-RESP-001

A rate limit hits unexpectedly

Time and unstable servers

How to run this card's commands yourself

1. The problem

In one sentence

The server starts answering 429 Too Many Requests after a number of calls, and the spec never said that this can happen.

A story

A client works well in testing with a few calls. In production, a batch job makes many calls in a row. After the third, the server answers 429. The spec lists 200 and 404 and nothing else. The client has no code for 429: no wait, no retry, no slow-down. It treats the answer as a failure, and the job stops half way, or it hammers the server and makes it worse.

Why it hurts

Rate limiting is good practice. The failure is that the contract does not mention it, so clients cannot behave well when they meet it.

  • For developers: a client that does not know about 429 cannot back off. It will either fail or retry at once, which keeps it throttled.
  • For managers: the first time customers meet the limit is at scale, in production, during a busy period. That is the worst time to learn the contract was incomplete.
  • For DevOps: declare 429 and the headers that tell clients when to retry (Retry-After), so integrations can respect them. Test the limit in a pre-production environment.

Example

A sandbox route that allows 3 calls and then refuses. The spec declares only 200:

GET /rate-limited  call 1  ->  200
GET /rate-limited  call 2  ->  200
GET /rate-limited  call 3  ->  200
GET /rate-limited  call 4  ->  429    (not declared)
GET /rate-limited  call 5  ->  429

In the failure-catalog demo, the third call to GET /items answers 429, and the spec declares 200 and 404.

How to detect it without clrsig

  • Loop the call quickly: for i in $(seq 1 10); do curl -s -o /dev/null -w '%{http_code}\n' URL; done.
  • Read the response headers of a 429: Retry-After and rate-limit headers tell clients how long to wait.

How to fix it

There are two usual causes:

  1. The spec is incomplete (more likely, since the limit is intended). Declare 429 for the operations that are limited, with the Retry-After header and a body, so clients know what to do.
  2. The limit is wrong. It is too low for normal use. Raise it, or give heavy clients their own limit.

To tell which: ask whether normal clients can hit the limit. If they can, the limit is wrong. If only abusive ones can, declare it.

AC-050 The server fails every few calls, AC-052 The server is down for a while and then recovers, AC-001 The server answers a status the spec never listed. Failure-catalog demo: FM-016-01. See also the site’s Rate-Limit and Throttling Failures.

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

2. How clrsig helps

Check

CS-RESP-001 Undeclared response status: the 429 is not declared, so each refused call is reported. State: caught, but only after the limit is reached, so the check needs several calls. A scenario that calls the route repeatedly does this.

Command

Save the scenario below as rate-limit.yaml. It sends one POST (the sandbox reset) and five GET requests:

Safety. Run this against a test server, never production. clrsig conform sends POST, PUT and DELETE requests built from the spec: start with --read-only, and take secrets from the environment (${NAME}), never from files in the repository.

schemaVersion: "1"
title: calls after the limit are refused
steps:
  - label: reset
    request: { method: POST, url: "{{baseUrl}}/__admin/reset" }
    assertions:
      - { type: status, operator: eq, expected: 204 }
    failPolicy: stop
  - label: call 1
    request: { method: GET, url: "{{baseUrl}}/rate-limited" }
    assertions:
      - { type: status, operator: eq, expected: 200 }
    failPolicy: continue
  - label: call 2
    request: { method: GET, url: "{{baseUrl}}/rate-limited" }
    assertions:
      - { type: status, operator: eq, expected: 200 }
    failPolicy: continue
  - label: call 3
    request: { method: GET, url: "{{baseUrl}}/rate-limited" }
    assertions:
      - { type: status, operator: eq, expected: 200 }
    failPolicy: continue
  - label: call 4
    request: { method: GET, url: "{{baseUrl}}/rate-limited" }
    assertions:
      - { type: status, operator: eq, expected: 200 }
    failPolicy: continue
  - label: call 5
    request: { method: GET, url: "{{baseUrl}}/rate-limited" }
    assertions:
      - { type: status, operator: eq, expected: 200 }
    failPolicy: continue
clrsig run rate-limit.yaml \
  --env clrsig/environments/conform-fail.yaml \
  --spec specs/conform-fail.yaml

Exit code: 0 all steps pass, 1 a step failed, 2 the scenario or the setup is broken. Here it is 1.

What you see

Output from clrsig v0.21.0, recorded on 2026-11-30:

Scenario: calls after the limit are refused

  PASS  reset  204  14ms
         ✓ status eq 204
  PASS  call 1  200  1ms
         ✓ status eq 200
  PASS  call 2  200  1ms
         ✓ status eq 200
  PASS  call 3  200  2ms
         ✓ status eq 200
  FAIL  call 4  429  2ms
         → The server answered 429, and its Retry-After header asks to wait 60 seconds before trying again. Check: Wait at least that long before sending it again. That may still not be enough. A scenario step’s retry settings do not read this header. For a limit on requests, check the API’s rate limits; for a service that is unavailable, check its status or maintenance notices. [CS-HINT-002]
         ✗ status eq 200: expected "200"; got "429"
         ✗ schema: GET /rate-limited answered 429, but the spec declares only 200
  FAIL  call 5  429  2ms
         → The server answered 429, and its Retry-After header asks to wait 60 seconds before trying again. Check: Wait at least that long before sending it again. That may still not be enough. A scenario step’s retry settings do not read this header. For a limit on requests, check the API’s rate limits; for a service that is unavailable, check its status or maintenance notices. [CS-HINT-002]
         ✗ status eq 200: expected "200"; got "429"
         ✗ schema: GET /rate-limited answered 429, but the spec declares only 200

Spec: 1 of 6 responses were not compared with the spec (no matching operation in the spec: 1)
FAILED  4 passed, 2 failed, 0 skipped  (4/8 assertions passed)  33ms

How to read it: calls 1 to 3 pass, and calls 4 and 5 are refused with 429. The schema line says 429 is not declared. The Spec: line says the reset call is not in the spec, which is expected here.

The failure-catalog demo fm-016-01-rate-limit shows the same on a small server (a GET scenario; from its folder, with Go installed):

cd failures/fm-016-01-rate-limit
go run broken/main.go &
clrsig run scenarios/detect.yaml --env environments/local.yaml

Output from clrsig v0.21.0, recorded on 2026-11-30:

Scenario: fm-016-01 — Rate-Limit and Throttling Failures

  PASS  request 1 — within rate limit, must return 200  200  13ms
         ✓ status eq 200
  PASS  request 2 — within rate limit, must return 200  200  0ms
         ✓ status eq 200
  FAIL  request 3 — must return 200 (broken server returns undeclared 429)  429  0ms
         → The server answered 429, and its Retry-After header asks to wait 1 second before trying again. Check: Wait at least that long before sending it again. That may still not be enough. A scenario step’s retry settings do not read this header. For a limit on requests, check the API’s rate limits; for a service that is unavailable, check its status or maintenance notices. [CS-HINT-002]
         ✗ status eq 200: expected "200"; got "429"
         ✗ schema: GET /items answered 429, but the spec declares only 200, 404

FAILED  2 passed, 1 failed, 0 skipped  (2/4 assertions passed)  14ms

Where to look

  • Desktop app: open the scenario and run it; each step shows its assertions.
  • Reports: --format json and junit on clrsig run.
  • GitHub Action: use command: run with the scenario, env and spec inputs; spec replaces the scenario’s specFile. Older releases of the Action ignored spec with run; if you use one, add specFile: specs/conform-fail.yaml to the scenario instead (the path is relative to the scenario file) (setup and upgrading).

How clrsig helps you fix it

It shows the exact call where the limit starts and that the status is not in the spec. It does not know the rate you intend.

Limits

  • A single conform run calls each operation once, so it will not reach a limit of 3 calls. Use repeated calls in a scenario.
  • It does not check that the Retry-After header is present and sensible.

More ways

Nothing yet.

3. Video brief for Google NotebookLM

VIDEO BRIEF — AC-051 · A rate limit hits unexpectedly
Length: 5 to 7 minutes. Language: English. Audience: developers, with a line each for managers and DevOps.
One idea: rate limiting is good practice, but if the contract does not mention it, clients cannot behave well when they meet it.
Open with this story: A client works well in testing with a few calls. In production, a batch job makes many calls in a row. After the third, the server answers 429 Too Many Requests. The spec lists 200 and 404 and nothing else. The client has no code for 429: no wait, no retry, no slow-down. It treats the answer as a failure, and the job stops half way, or it hammers the server and makes it worse.
Say these facts, in this order:
1. The sandbox route allows 3 calls and then answers 429. The spec declares only 200.
2. The scenario calls it five times. Calls 1 to 3 pass; calls 4 and 5 answer 429 and fail, with the schema line saying 429 is not declared.
3. A demo from the failure catalog does the same on its third call.
4. A single conform run calls each operation once and would not reach the limit.
5. Two usual causes: the spec is incomplete (declare 429 with the Retry-After header and a body), or the limit is too low for normal use.
6. For managers: customers first meet the limit at scale, in production, during a busy period.
7. For DevOps: declare 429 and the headers that tell clients when to retry; test the limit before production.
Show on screen: the five-call list, the scenario YAML, the commands (clrsig run rate-limit.yaml --env clrsig/environments/conform-fail.yaml --spec specs/conform-fail.yaml), and the first output block, copied exactly from the card.
Name the check: CS-RESP-001, Undeclared response status. Say the clrsig version: v0.21.0.
Explain these words once: rate limit (a cap on how many calls a client may make in a time); 429 (too many requests); Retry-After (a header that says how long to wait); backoff (waiting longer after each failure); exit code (0 clean, 1 a finding, 2 setup or spec broken).
Say what clrsig does not see here: a single conform run does not reach a limit of three calls; it does not check that the Retry-After header is present and sensible.
Safety line (if a write is shown): Run this against a test server, never production. clrsig conform sends POST, PUT and DELETE requests built from the spec: start with --read-only, and take secrets from the environment (${NAME}), never from files in the repository.
Finish with three recap questions:
1. Which status means too many requests? (429.)
2. Why is the first meeting with a limit in production a problem? (The contract did not say it can happen.)
3. Which header tells clients how long to wait? (Retry-After.)
Tease the next video: AC-052 · The server is down for a while and then recovers.
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.