EveryDocumentation Index
Fetch the complete documentation index at: https://docs.markapidown.net/llms.txt
Use this file to discover all available pages before exploring further.
mad command exits with a well-defined numeric code. These codes are stable across releases, which means you can safely branch on them in shell scripts, Makefile targets, and CI pipeline steps without worrying about them changing between versions. The table below covers all six codes, what triggers each one, and how to handle them reliably.
Exit code reference
| Code | Meaning | When it occurs |
|---|---|---|
0 | Passed | All specs are valid and all assertions passed. The actual response matched the ## Expected response block. |
1 | Test failed | The request was sent and a response was received, but one or more assertions or expected-response comparisons did not match. |
2 | Invalid spec | The spec file is malformed — bad frontmatter, a missing required section, an unresolved {{variable}} reference, or an --env value with no matching heading in env.md. |
3 | Engine error | An internal execution error prevented MarkApiDown from building the HTTP request (unsupported protocol, filesystem error, corrupted binary). |
4 | Network error | The request was built and dispatched but no response arrived — DNS failure, connection refused, or timeout exhausted across all retry attempts. |
5 | Secret detected | A value matching a known secret pattern was found in a versioned markdown file. mad exits immediately before any network request is made. |
When each code fires in detail
Code 1 — Test failed The request succeeded at the transport level, but the response diverged from the spec. Check the diff output (or use--output=json to parse the assertions array) to see exactly which fields did not match.
Code 2 — Invalid spec
MarkApiDown could not construct a valid request from the file. The error message always includes the file path, the line number when available, and a suggested fix. Common causes: typo in frontmatter, a {{variable}} with no definition in any environment file or .env.local, or a pipeline step referencing a non-existent endpoint file.
Code 3 — Engine error
An internal failure occurred after the spec was parsed but before the request was sent. Common causes: an unsupported value for the protocol frontmatter key, a filesystem error while reading an included file, or a missing feature compiled out of the binary. Run mad --verbose for full stack context.
Code 4 — Network error
MarkApiDown reached the send stage but got no response. This covers DNS resolution failure, refused connections, and timeout expiry across all configured retry attempts. Check VPN status, service health, or whether baseUrl is set correctly in your environment file.
Code 5 — Secret detected
mad scans spec content for patterns matching JWTs, hex API keys, sk_-prefixed keys, and similar secrets before making any network call. When a match is found the process exits code 5 immediately. Move the value to .env.local (which is auto-added to .gitignore by mad init) or export it as a MAD_* environment variable.
Using exit codes in shell scripts
Test the exit code directly in anif statement to branch on success or failure:
$? to distinguish between failure types:
case statement to handle every code explicitly:
Using exit codes in Makefile targets
Integratemad into your build pipeline using standard Makefile idioms. The .PHONY declaration prevents Make from confusing targets with files of the same name.
mad as a recipe line. Make stops immediately if a recipe command returns non-zero.
Using exit codes in GitHub Actions
GitHub Actions fails a step whenever the command exits non-zero, so a baremad exec call is enough to fail the job on a test failure. Use the steps below to also capture a JUnit report as a downloadable artifact and a test-summary annotation.