AC-059 Spec file caught CS-RUN-004

The spec is broken in a way a tool must explain

The spec file

How to run this card's commands yourself

1. The problem

In one sentence

The spec is valid YAML, but it is not a valid OpenAPI document: it refers to something that does not exist, or it contradicts itself.

A story

A team splits a big spec into parts and moves a schema to another file. One $ref still points at #/components/schemas/Nope, a schema that no longer exists. The file parses, so the editor shows no error. The documentation generator prints a blank page, the code generator fails with a stack trace, and the test tool refuses to start. Two more mistakes of the same kind: two operations share the same operationId, and a path /u/{id} has no declared id parameter.

Why it hurts

A broken spec is worse than a missing one, because it looks fine until a tool tries to use it. The mistakes are easy to make, and each tool reports them differently.

  • For developers: the error is usually a reference, an id or a parameter that does not match. The fix is small, but finding it from a generated stack trace is not.
  • For managers: an unreadable spec blocks every consumer at once: documentation, SDKs, mocks, tests, gateway rules.
  • For DevOps: a spec lint or a parse step at the start of the pipeline turns a mysterious later failure into a clear early one.

Example

Three small broken specs from the sandbox:

a $ref to a schema that does not exist       #/components/schemas/Nope
two operations with the same operationId     "same", on GET /one and GET /two
a path parameter that is not declared        GET /u/{id} with no id parameter

How to detect it without clrsig

  • Run an OpenAPI linter or validator on the file. Any decent one reports these three.
  • Load the spec with a library for your language: the load fails with a message about the reference or the id.

How to fix it

Each message points at one exact thing:

  1. A missing reference: add the schema, or fix the name in the $ref.
  2. A duplicate operationId: give each operation a unique id. Ids become the names of generated functions, so keep them readable.
  3. An undeclared path parameter: declare the {id} as a parameter with in: path and required: true. To tell where the mistake is: read the operation or path named in the message. Never fix it by deleting the operation, unless it is truly gone.

AC-058 The spec cannot be read, AC-054 A spec change breaks existing clients. Words used on this page are explained once in the glossary.

2. How clrsig helps

Check

CS-RUN-004 Spec cannot be read, here for a spec that parses but is not valid. State: caught. The result is an error with exit code 2, which is different from 1. clrsig never crashes and never sends a request for a spec like this.

Command

clrsig generate --dry-run reads the spec and builds the requests without sending anything. Run the three from the sandbox folder:

clrsig generate specs/hostile/missing-ref.yaml --dry-run
clrsig generate specs/hostile/duplicate-operation-id.yaml --dry-run
clrsig generate specs/hostile/undeclared-path-param.yaml --dry-run

Exit code: 0 clean, 1 a finding, 2 the spec or the setup is broken. Here each is 2.

What you see

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

Error: parsing spec: loading spec: failed to resolve "components" in fragment in URI: "#/components/schemas/Nope"

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

Error: parsing spec: invalid OpenAPI spec: invalid paths: operations "GET /one" and "GET /two" have the same operation id "same"

Output from clrsig v0.21.0, recorded on 2026-11-30. The undeclared path parameter:

Error: parsing spec: invalid OpenAPI spec: invalid paths: operation GET /u/{id} must define exactly all path parameters (missing: [id])

How to read it: each message names the thing that is wrong (the reference, the two operations, the missing parameter). They are the validator’s own words; clrsig does not add a “fix” line for these.

Where to look

  • Exit code: 2 tells a script that the spec is broken, not that the API failed a check.
  • Other commands: conform, run, diff and coverage stop the same way for such a spec.
  • GitHub Action: the Action has no generate command. Its conform command stops with the same message (exit code 2), and validate with the spec input reports it as a parse error (exit code 1).

How clrsig helps you fix it

It stops early with a message that names the exact reference, operations or parameter, so you do not wait for a tool to fail later. It does not repair the spec.

Limits

  • The messages are the validator’s and are written for people who know OpenAPI. They do not explain the fix.
  • Only the first error is shown. Fix it and run again.

More ways

Nothing yet.

3. Video brief for Google NotebookLM

VIDEO BRIEF — AC-059 · The spec is broken in a way a tool must explain
Length: 5 to 7 minutes. Language: English. Audience: developers, with a line each for managers and DevOps.
One idea: a spec can be valid YAML and still be broken OpenAPI; a broken spec looks fine until a tool tries to use it.
Open with this story: A team splits a big spec into parts and moves a schema to another file. One reference still points at a schema that no longer exists. The file parses, so the editor shows no error. The documentation generator prints a blank page, the code generator fails with a stack trace, and the test tool refuses to start.
Say these facts, in this order:
1. Three broken specs: a reference to a schema that does not exist, two operations with the same operation id, and a path parameter that is not declared.
2. clrsig generate with dry-run reads the spec and builds requests without sending anything.
3. Each case stops with an error and exit code 2, and a message that names the exact thing: the reference, the two operations, the missing parameter.
4. clrsig never crashes and never sends a request for a spec like this.
5. How to fix each: add the schema or fix the reference; give each operation a unique id; declare the parameter in the path with required true.
6. Only the first error is shown; fix it and run again.
7. For managers: a broken spec blocks every consumer at once.
8. For DevOps: a lint or a parse step at the start of the pipeline turns a mysterious later failure into a clear early one.
Show on screen: the three examples, the three commands, and the three output blocks, copied exactly from the card.
Name the check: CS-RUN-004, Spec cannot be read. Say the clrsig version: v0.21.0.
Explain these words once: operation id (a unique name for one operation in the spec); $ref (a pointer to another part of the spec); path parameter (a value inside the URL path, such as the id in /u/7); exit code (0 clean, 1 a finding, 2 setup or spec broken).
Say what clrsig does not see here: the messages are the validator's own and do not explain the fix; only the first error is shown.
Safety line (if a write is shown): not needed, nothing is sent.
Finish with three recap questions:
1. Why does the editor show no error for a missing reference? (The file is valid YAML.)
2. What does an operation id become in generated code? (The name of a function.)
3. What exit code do these three cases give? (2.)
Tease the next video: this is the last episode of the series; point back to the first one, AC-001 · The server answers a status the spec never listed.
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.