AC-050 Scenario caught CS-RESP-001

The server fails every few calls

Time and unstable servers

How to run this card's commands yourself

1. The problem

In one sentence

The server answers correctly most of the time, and fails on some calls, for no reason the client can see.

A story

An endpoint is correct on calls 1 and 2, and answers 500 Internal Server Error on call 3. Calls 4 and 5 are fine; call 6 fails again. The cause might be one bad instance behind the load balancer, a connection pool that runs out, or a dependency that fails now and then. In a test with one request, it passes. In production, one customer in three sees an error.

Why it hurts

Intermittent failures are the hardest to fix, because they cannot be reproduced on demand. They also erode trust: users retry, support cannot reproduce, and the team stops believing the test results.

  • For developers: a test that passes once says little. You need to repeat the call enough times to see the rate, and keep the result of every call.
  • For managers: a one-in-three failure looks like a small error rate in a dashboard, but every user meets it within a few actions.
  • For DevOps: a flaky route behind a load balancer often means one unhealthy instance. Look at failures per instance, and make health checks match real behaviour.

Example

A sandbox route that fails on every third call. The spec declares only 200:

GET /flaky  call 1  ->  200
GET /flaky  call 2  ->  200
GET /flaky  call 3  ->  500
GET /flaky  call 4  ->  200
GET /flaky  call 5  ->  200
GET /flaky  call 6  ->  500

How to detect it without clrsig

  • Loop the call: for i in $(seq 1 30); do curl -s -o /dev/null -w '%{http_code}\n' URL; done | sort | uniq -c shows the share of failures.
  • Check the logs per instance for the failing calls.

How to fix it

There are two usual causes:

  1. The server is wrong (more likely). Find what fails: an instance, a pool, a dependency. Fix the cause, and make clients’ retries safe (AC-042).
  2. The spec is incomplete. If the failure is expected and transient (a 503 during a restart), declare it, so clients handle it on purpose with a retry and a limit.

To tell which: ask whether the failure is a bug or a known, temporary condition. Never hide it by retrying silently.

AC-052 The server is down for a while and then recovers, AC-051 A rate limit hits unexpectedly, AC-044 A write times out, yet it was done.

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

2. How clrsig helps

Check

CS-RESP-001 Undeclared response status: the 500 is not declared, so each failing call is reported. State: caught, but only on the calls where the failure happens. A single call can pass by luck. A scenario that calls the route repeatedly shows the pattern.

Command

Save the scenario below as flaky.yaml (a reset, then six calls). It sends one POST (the sandbox reset) and six 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: every third call fails
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}}/flaky" }
    assertions:
      - { type: status, operator: eq, expected: 200 }
    failPolicy: continue
  - label: call 2
    request: { method: GET, url: "{{baseUrl}}/flaky" }
    assertions:
      - { type: status, operator: eq, expected: 200 }
    failPolicy: continue
  - label: call 3
    request: { method: GET, url: "{{baseUrl}}/flaky" }
    assertions:
      - { type: status, operator: eq, expected: 200 }
    failPolicy: continue
  - label: call 4
    request: { method: GET, url: "{{baseUrl}}/flaky" }
    assertions:
      - { type: status, operator: eq, expected: 200 }
    failPolicy: continue
  - label: call 5
    request: { method: GET, url: "{{baseUrl}}/flaky" }
    assertions:
      - { type: status, operator: eq, expected: 200 }
    failPolicy: continue
  - label: call 6
    request: { method: GET, url: "{{baseUrl}}/flaky" }
    assertions:
      - { type: status, operator: eq, expected: 200 }
    failPolicy: continue
clrsig run flaky.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: every third call fails

  PASS  reset  204  17ms
         ✓ status eq 204
  PASS  call 1  200  1ms
         ✓ status eq 200
  PASS  call 2  200  2ms
         ✓ status eq 200
  FAIL  call 3  500  2ms
         ✗ status eq 200: expected "200"; got "500"
         ✗ schema: GET /flaky answered 500, but the spec declares only 200
  PASS  call 4  200  2ms
         ✓ status eq 200
  PASS  call 5  200  2ms
         ✓ status eq 200
  FAIL  call 6  500  2ms
         ✗ status eq 200: expected "200"; got "500"
         ✗ schema: GET /flaky answered 500, but the spec declares only 200

Spec: 1 of 7 responses were not compared with the spec (no matching operation in the spec: 1)
FAILED  5 passed, 2 failed, 0 skipped  (5/9 assertions passed)  38ms

How to read it: calls 3 and 6 fail, so the failure is periodic. The schema line is the spec check: 500 is not declared. The Spec: line says the reset call is not in the spec, which is expected here.

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 gives you the call numbers and the statuses, which is the evidence of a pattern. It cannot say which instance or dependency fails.

Limits

  • A single conform run calls each operation once, so a flaky route can pass by luck. Repeat the call in a scenario, or run the check several times.
  • It reports the failures it sees; it does not compute a failure rate.

More ways

Nothing yet.

3. Video brief for Google NotebookLM

VIDEO BRIEF — AC-050 · The server fails every few calls
Length: 5 to 7 minutes. Language: English. Audience: developers, with a line each for managers and DevOps.
One idea: an intermittent failure cannot be seen in one request; call the route enough times to see the pattern.
Open with this story: An endpoint is correct on calls 1 and 2, and answers 500 on call 3. Calls 4 and 5 are fine; call 6 fails again. The cause might be one bad instance behind the load balancer, a connection pool that runs out, or a dependency that fails now and then. In a test with one request it passes. In production, one customer in three sees an error.
Say these facts, in this order:
1. The scenario calls the route six times, and each call must answer 200.
2. Calls 3 and 6 answer 500. The spec declares only 200, so the 500 is also reported as an undeclared status.
3. A single call can pass by luck; repeat the call to see the pattern.
4. Two usual causes: the server is wrong (find the instance, pool or dependency that fails), or the failure is expected and transient and the spec should declare it.
5. Do not hide it with silent retries; make retries safe first.
6. For managers: a one-in-three failure looks small on a dashboard, but every user meets it within a few actions.
7. For DevOps: a flaky route behind a load balancer often means one unhealthy instance; look at failures per instance.
Show on screen: the six-call list, the scenario YAML, the command (clrsig run flaky.yaml --env clrsig/environments/conform-fail.yaml --spec specs/conform-fail.yaml), and the 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: flaky (works sometimes and fails sometimes); load balancer (a system that spreads requests over several servers); instance (one running copy of a server); exit code (0 clean, 1 a finding, 2 setup or spec broken).
Say what clrsig does not see here: a single conform run calls each operation once, so a flaky route can pass by luck; it does not compute a failure rate.
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. Why does one request not show a flaky failure? (It can pass by luck.)
2. Which calls failed in the scenario? (Calls 3 and 6.)
3. What often causes a flaky route behind a load balancer? (One unhealthy instance.)
Tease the next video: AC-051 · A rate limit hits unexpectedly.
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.