Skip to content

exit 8 when Common Crawl cannot be reached - #132

Merged
tamnd merged 1 commit into
mainfrom
transport-exit-code
Aug 12, 2026
Merged

tamnd merged 1 commit into
mainfrom
transport-exit-code

Conversation

@tamnd

@tamnd tamnd commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Closes #131.

The help lists exit 8 as "transport failure, the bytes did not arrive". One command returned it. cli/download.go:157 was the only errs.KindNetwork in the tree, so every other command that could not reach Common Crawl exited 1, which is the code for anything at all.

index.commoncrawl.org has been refusing connections for two days, so this was easy to see: crawls latest, search, and get all exited 1 with "connect: connection refused", indistinguishable from a bad crawl ID or a malformed pattern.

The change

The retry loop in ccrawl/client.go marks its exhaustion with ErrTransport when the last failure came from the transport rather than from a status the server sent. cli classifies that as errs.KindNetwork.

An exhausted 503 stays exit 1. The server was there and said no, and telling a supervisor otherwise sends it into a loop against a source that is up and refusing.

errs.KindOf walks the error chain, so classifying once at the point the transport gives up reaches the CLI, HTTP, and MCP surfaces together. ccrawl still does not import the framework: it exports a plain sentinel and cli does the classifying.

It is applied where commands are registered rather than in 34 handlers: handle over kit.Handle, and addCmd/addCmdUnder over AddCommand/AddCommandUnder, which walk the Sub tree. TestEveryHandlerIsClassified walks the source and fails on a registration that goes around them, since kit builds its cobra tree privately and a test cannot ask the binary what it registered. It counts 53 classified registrations today.

Measured against the live outage

command exit why
crawls latest 8 connect: connection refused
crawls list 8 connect: connection refused
search example.com/* 8 connect: connection refused
get example.com 8 connect: connection refused
paths bogus 8 connect: connection refused
rank host 2 expected at least 1 argument
rank top --graph nope-2020 -n 1 1 Rank table HTTP 404
download warc -n 1 --source s3 8 no AWS credentials
rank host wikipedia.org 0
paths warc -c CC-MAIN-2025-05 0

Before the change the first five were all 1.

The two unit tests on the ccrawl side use a closed port and a permanent 503 rather than the outage, so they keep working once Common Crawl comes back.

Docs

The exit codes reference named download as the only source of 8. It now describes what 8 means for every command, shows the outage as it looks from the shell, and carries a supervisor snippet that backs off on 8 and stops on anything else. The one thing that stays scoped to download is that it reports any download failure as a transport failure, --source s3 without credentials included.

Checks

gofmt, go vet, go test ./..., golangci-lint (0 issues), scripts/docs-drift.sh, scripts/coverage.sh all clean. cli coverage 52.4 to 52.6.

The help lists exit 8 as "transport failure, the bytes did not
arrive". One command returned it. cli/download.go was the only
errs.KindNetwork in the tree, so every other command that could not
reach Common Crawl exited 1, which is the code for anything at all.

index.commoncrawl.org has been refusing connections for two days, so
this was easy to see: crawls latest, search, and get all exited 1 with
"connect: connection refused", indistinguishable from a bad crawl ID.

The retry loop in ccrawl/client.go now marks its exhaustion with
ErrTransport when the last failure came from the transport rather than
from a status the server sent, and cli classifies that as
errs.KindNetwork. An exhausted 503 stays exit 1: the server was there
and said no, and telling a supervisor otherwise sends it into a loop
against a source that is up and refusing.

errs.KindOf walks the error chain, so classifying once at the point
the transport gives up reaches the CLI, HTTP, and MCP surfaces
together. It is applied where commands are registered rather than in
34 handlers: handle over kit.Handle, addCmd and addCmdUnder over
AddCommand and AddCommandUnder, which walk the Sub tree.
TestEveryHandlerIsClassified walks the source and fails on a
registration that goes around them, since kit builds its cobra tree
privately and a test cannot ask the binary what it registered.

Measured against the live outage:

  crawls latest                8   connect: connection refused
  crawls list                  8   connect: connection refused
  search example.com/*         8   connect: connection refused
  get example.com              8   connect: connection refused
  paths bogus                  8   connect: connection refused
  rank host                    2   expected at least 1 argument
  rank top --graph nope-2020   1   Rank table HTTP 404
  download -n 1 --source s3    8   no AWS credentials
  rank host wikipedia.org      0
  paths warc -c CC-MAIN-2025-05  0

Closes #131
@tamnd tamnd added this to the v0.10.1 milestone Aug 12, 2026
@tamnd tamnd added type: bug Something is wrong type: docs Documentation area: transport HTTP client, S3, rate limiting area: cli Command surface, flags, config labels Aug 12, 2026
@tamnd
tamnd merged commit 102a6e9 into main Aug 12, 2026
8 checks passed
@tamnd
tamnd deleted the transport-exit-code branch August 12, 2026 18:53
@github-actions github-actions Bot mentioned this pull request Aug 12, 2026
34 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command surface, flags, config area: transport HTTP client, S3, rate limiting type: bug Something is wrong type: docs Documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A network failure exits 1, and the help says it exits 8

1 participant