AC-058 Spec file caught CS-RUN-004

The spec cannot be read

The spec file

How to run this card's commands yourself

1. The problem

In one sentence

The file that is supposed to describe the API is missing, has a typo in its path, or is not valid YAML or JSON, so nothing can read it.

A story

A pipeline step runs the API checks against specs/orders.yaml. Last week the file was renamed to specs/order-api.yaml. The step fails, and the log says something short and technical. In a second project, someone edited the spec by hand and left out a colon. The YAML no longer parses. Every tool that reads the spec (documentation, code generators, test tools, the gateway) fails in its own way.

Why it hurts

The spec is the source of truth that many tools share. When it cannot be read, everything that depends on it stops, or worse, silently falls back to the last copy it had.

  • For developers: a parse error often points at a line far from the real mistake (a missing colon shows up as “did not find expected key” at the next line).
  • For managers: a broken spec blocks releases, documentation and partner integrations at the same time, for a reason that takes minutes to fix once found.
  • For DevOps: the spec should be checked as soon as it changes, before anything else uses it. A fast parse check at the start of the pipeline gives the clearest error.

Example

The path is wrong. The file does not exist:

specs/does-not-exist.yaml        (the file was renamed)

Or the file is there and is not valid YAML. Here a colon is missing after the "200" key:

openapi: 3.0.3
info:
  title: broken yaml
  version: "1"
paths:
  /things:
    get:
      responses:
        "200"
          description: missing colon above

How to detect it without clrsig

  • Check that the path exists, and open the file.
  • Run the file through any YAML or JSON parser (python -c 'import yaml,sys; yaml.safe_load(open(sys.argv[1]))' FILE, or an editor with a YAML check), and read the line number.

How to fix it

There are two usual causes:

  1. The path or the name is wrong (a rename, a moved folder, a typo). Point the tool at the right file, and keep the path in one place (a variable or a config file).
  2. The file has a syntax error. Fix it at the line shown or just above it. Keep the spec under version control, so the last good version is one git diff away. To tell which: look at the first line of the message. “Cannot find” means the path, “parsing” means the content.

AC-059 The spec is broken in a way a tool must explain, 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. State: caught. The spec file or address is missing, or does not parse. The result is an error with exit code 2, which is different from 1 (a real finding), and no request is sent.

Command

Two runs. Nothing is sent, because the spec is not read; the same command against a valid spec would send requests, so the safety rule applies to it:

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. The first path does not exist; the second file is the broken YAML above, saved as not-yaml.yaml:

clrsig conform specs/does-not-exist.yaml -b http://localhost:8080/x
clrsig conform not-yaml.yaml -b http://localhost:8080/x

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

What you see

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

Error: reading spec: open specs/does-not-exist.yaml: The system cannot find the file specified.

Output from clrsig v0.21.0, recorded on 2026-11-30. The file with a syntax error:

Error: parsing spec: loading spec: failed to unmarshal data: yaml error: yaml: line 10: did not find expected key

How to read it: reading spec means the file could not be opened. parsing spec means it could be read and is not valid. The line number is where the parser noticed, often one line after the real mistake. The words in the first message depend on your operating system.

Where to look

  • Exit code: a script can tell 2 (the setup or the spec is broken) from 1 (the API disagrees with the spec).
  • GitHub Action: it runs the same command, so the step fails with the same message.
  • Other commands: clrsig generate, diff and coverage also stop with 2 for a spec that cannot be read.

How clrsig helps you fix it

It stops at once, with a short message and the exit code 2, and never sends a request or crashes. It names the stage (reading or parsing) and the line.

Limits

  • The message is the parser’s own. It does not suggest the fix.
  • A spec that parses but is not a valid OpenAPI document is the next card (AC-059).

More ways

Nothing yet.

3. Video brief for Google NotebookLM

VIDEO BRIEF — AC-058 · The spec cannot be read
Length: 5 to 7 minutes. Language: English. Audience: developers, with a line each for managers and DevOps.
One idea: the spec is the source of truth many tools share; if it cannot be read, everything that depends on it stops.
Open with this story: A pipeline step runs the API checks against a spec file. Last week the file was renamed. The step fails and the log says something short and technical. In a second project, someone edited the spec by hand and left out a colon. The YAML no longer parses, and every tool that reads the spec fails in its own way.
Say these facts, in this order:
1. Two failures: the path is wrong, so the file is missing; or the file is there and is not valid YAML.
2. clrsig stops at once with an error and the exit code 2. It sends no request and does not crash.
3. Exit code 2 means the spec or the setup is broken; exit code 1 means the API disagrees with the spec.
4. The message says reading spec for a missing file and parsing spec for a syntax error; the YAML message names a line, often one line after the real mistake.
5. Two usual causes: the path or the name is wrong, or the file has a syntax error.
6. Keep the spec under version control, so the last good version is one diff away.
7. For managers: a broken spec blocks releases, documentation and partner integrations at the same time.
8. For DevOps: check the spec first, before anything else uses it.
Show on screen: the missing path, the broken YAML, the two commands (clrsig conform specs/does-not-exist.yaml -b http://localhost:8080/x and clrsig conform not-yaml.yaml -b http://localhost:8080/x), and the two 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: spec (the OpenAPI file that describes the API); YAML (a text format for structured data, used by most specs); parse (read a file and understand its structure); exit code (0 clean, 1 a finding, 2 setup or spec broken).
Say what clrsig does not see here: the message is the parser's own and does not suggest the fix; a spec that parses but is not valid OpenAPI is a different problem.
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 exit code means the spec or the setup is broken? (2.)
2. What is the difference between reading spec and parsing spec? (The file could not be opened, or it was opened and is not valid.)
3. Where is a YAML error often really located? (One line before the line it names.)
Tease the next video: AC-059 · The spec is broken in a way a tool must explain.
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.