AC-046 Scenario not caught

An async job never finishes

State, retries and concurrency

How to run this card's commands yourself

1. The problem

In one sentence

A long task is started through the API, and its status never moves from processing to completed.

A story

A client asks for a report with POST /jobs. The server answers 201 Created and a job id, which is what the spec says. The client then polls GET /jobs/1 to learn when the report is ready. The status says processing. It says processing an hour later and a day later. The part of the system that moves the job forward was never built, or it crashed and nobody noticed. The answers are valid every time.

Why it hurts

Asynchronous operations are a contract in two parts: “I accept the work” and “here is how you learn the result”. If the second part never happens, the first is a lie.

  • For developers: the failure is in a worker or queue outside the request path. The API itself looks healthy, with valid 201 and 200 answers and a valid status value.
  • For managers: customers wait for reports, exports and imports that never arrive. There is no error to alert on, only a status that does not change.
  • For DevOps: monitor the age of jobs in processing, not just request errors. A job that stays in a state past its expected time is the alarm.

Example

In a failure-catalog demo:

POST /jobs {"type":"report"}   ->  201 Created
GET  /jobs/1                   ->  {"status":"processing"}    (should become "completed")

How to detect it without clrsig

  • Create a job, then poll the status for longer than the normal run time. If it never changes, the worker is not running.
  • Look at the queue or worker logs for jobs that were taken and never finished.

How to fix it

There are two usual causes:

  1. The worker is missing or broken (more likely). Implement it, restart it, and make failures move the job to a failed state, so a job never stays in processing forever.
  2. The spec does not describe the lifecycle. Declare the states (processing, completed, failed), what moves a job between them, and how long a job may take.

To tell which: look at whether anything ever moves a job on. Never leave a job without a final state.

AC-044 A write times out, yet it was done, AC-045 A stale read after a write, AC-040 A business rule is broken though every response looks fine. See also the site’s Long-Running Operation and Asynchronous API Failures.

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

2. How clrsig helps

Check

No built-in check, and the state is not caught: each answer is valid and matches its schema. A scenario that creates a job and then asserts its final status finds it.

Command

This demo is a runnable server in the failure catalog. The scenario sends a POST to its own local toy server, so it writes data there:

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.

cd failures/fm-028-01-async-job
go run broken/main.go &
clrsig run scenarios/detect.yaml --env environments/local.yaml

Exit code: 0 all steps pass, 1 a step failed, 2 the scenario or the setup is broken. Here it is 1. Against fixed/main.go both steps pass and the exit code is 0.

What you see

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

Scenario: fm-028-01 — Async Job Status Never Transitions

  PASS  POST /jobs — create a new job  201  13ms
         ✓ status eq 201
  FAIL  GET /jobs/1 — status must be completed, not stuck at processing  200  0ms
         ✗ jsonpath $.status eq completed: expected "completed"; got "processing"

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

How to read it: the job is created (201), and the status is still processing. In this demo the fixed server finishes at once, so the scenario reads the status one time. For a real job that takes longer, the read must come after the expected run time.

Where to look

  • Desktop app: open the scenario and run it; each step shows its assertion result.
  • Reports: --format json and junit on clrsig run.
  • GitHub Action: use command: run with the scenario and env inputs. The demo checks with its own assertions. To compare your own responses with your spec, name it with specFile in the scenario, or give the spec input, which replaces it; older releases of the Action ignored that input with run (setup and upgrading).

How clrsig helps you fix it

It shows the status the job is stuck in, and the status it should have reached. It cannot see the worker or the queue.

Limits

  • The scenario reads the status once. For a job that needs seconds or minutes, you must allow for that time yourself; the demo does not show waiting.
  • It checks the end state, not the time it took.

More ways

Nothing yet.

3. Video brief for Google NotebookLM

VIDEO BRIEF — AC-046 · An async job never finishes
Length: 5 to 7 minutes. Language: English. Audience: developers, with a line each for managers and DevOps.
One idea: an asynchronous API makes two promises, accept the work and tell the result; if the second never happens, the first is a lie.
Open with this story: A client asks for a report. The server answers 201 Created and a job id. The client then asks for the job's status. It says processing. It says processing an hour later and a day later. The part of the system that moves the job forward was never built, or it crashed and nobody noticed. The answers are valid every time.
Say these facts, in this order:
1. The scenario has two steps: create a job and expect 201, then read the job and expect the status completed.
2. On the broken server the first step passes and the second fails: expected completed, got processing.
3. Every answer is valid, so only a check of the final status finds it.
4. In the demo the fixed server finishes at once; for a real job you must allow for its run time.
5. Two usual causes: the worker is missing or broken (implement it, and let failures move the job to a failed state), or the spec does not describe the lifecycle.
6. For managers: customers wait for exports that never arrive; there is no error to alert on.
7. For DevOps: monitor the age of jobs in processing, not just request errors.
Show on screen: the two example lines, the commands (go run broken/main.go and clrsig run scenarios/detect.yaml --env environments/local.yaml), and the output block, copied exactly from the card.
Name the check: none built in; found by asserting the final status in a scenario. Say the clrsig version: v0.21.0.
Explain these words once: asynchronous (work that is started now and finished later); worker (a background process that does the work); lifecycle (the states a thing moves through); exit code (0 clean, 1 a finding, 2 setup or spec broken).
Say what clrsig does not see here: the worker and the queue; the scenario reads the status once and does not show waiting; it checks the end state, not the time taken.
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. What are the two promises of an asynchronous API? (Accept the work, and tell the result.)
2. Why do the answers look healthy? (Each one is valid.)
3. What should a failed job do? (Move to a failed state, never stay in processing forever.)
Tease the next video: AC-047 · A batch operation is not atomic.
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.