feat(errs): http error classifier - #566
Merged
Merged
Conversation
mnoah1
marked this pull request as ready for review
August 11, 2026 16:24
mnoah1
requested review from
a team,
behinddwalls and
sbalabanov
as code owners
August 11, 2026 16:24
behinddwalls
left a comment
Collaborator
There was a problem hiding this comment.
Solid, well-documented change. The per-node Classifier contract is respected (direct type assertions, no errors.As), the ordering hazard vs. mysqlerrs is real and correctly documented — I confirmed *url.Error does satisfy net.Error, so mysqlerrs would claim it if listed first — and the tests cover both the node-level and processor-level shapes.
Four things worth resolving, inline, roughly in order of consequence:
- Duplicate builds — 5xx on
CreateBuild(a non-idempotent POST) is now retryable, and the build controller has no guard that would stop a retry from starting a second Buildkite build. context.DeadlineExceeded— the deferral to "the generic classifier" doesn't land: generic returnsUnknownfor it, and onlymysqlerrs'net.Errorrule catches it. A service wiringgeneric+httpwithoutmysqldead-letters client timeouts.- GH Actions client unconverted — same service, both runners, only one gets the benefit.
- No test that the Buildkite client returns
*StatusError.
Plus two nits.
mnoah1
force-pushed
the
mnoah1/errs-http-classifier
branch
from
August 11, 2026 20:15
d0731dd to
35b345e
Compare
platform/errs treats an unclassified error as non-retryable, so every HTTP failure an extension returned took that default. A 502 from a proxy in front of a build API was indistinguishable from "this request is invalid": the message dead-lettered on its first attempt instead of being retried. Add platform/http.StatusError, a typed error that keeps the status code in the chain, and platform/errs/http, the classifier that reads it. Server-state codes (500, 502, 503, 504, other 5xx, 429, 408) are retryable dependency errors; verdicts on the request (4xx, 3xx, and the permanently broken 501 and 505) are not. *url.Error covers transport failures, except when it wraps our own context cancellation — that node is left to the generic classifier so shutdowns stay out of a backend's dependency metrics. The classifier must be listed before platform/errs/mysql, whose net.Error rule matches *url.Error and would otherwise claim HTTP transport failures. Documented in the errs README next to the wiring example. Convert the Buildkite client to return the typed error and wire the classifier into the stovepipe server. The GitHub Actions client and the other services still format their status codes into strings and are unchanged here.
- Stop declining context.DeadlineExceeded. Only context.Canceled is left to the generic classifier now. A deadline that elapses mid-request means the remote end did not answer in time, so it belongs to the dependency; declining it also stranded the node, because generic matches only Canceled and nothing else claimed it unless platform/errs/mysql happened to be wired. A processor test with just generic + http pins that the classifier stands on its own. - Bound StatusError.Error to 1 KiB of body. The rendered string reaches the queue's dead-letter record through Reject(ctx, err.Error()) and last_error is finite, so a large error page could fail that write and leave the message stuck instead of dead-lettered. Body is still kept whole. - Convert the GitHub Actions client's two status paths as well. Stovepipe runs both build runners, so leaving one untyped meant a 502 was retried or dead-lettered depending only on which runner the queue used. - Assert with errors.As that both clients return *StatusError and carry the code. The old tests only checked that an error came back, so they passed before the typed error existed and would keep passing if it were reverted. - Document that a retried create can duplicate a build, on both clients' create paths. Note that codes below 100, including 0, take the non-retryable fall-through deliberately, and cover 0 in the table.
The runners now reach for platform/errs and platform/http to mark a create that may have taken effect as non-retryable, which gazelle has to see.
mnoah1
force-pushed
the
mnoah1/errs-http-classifier
branch
from
August 11, 2026 21:22
88b082c to
468182f
Compare
mnoah1
enabled auto-merge
August 11, 2026 21:25
behinddwalls
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
platform/errs treats an unclassified error as non-retryable, so every HTTP failure an extension returned took that default. A 502 from a proxy in front of a build API was indistinguishable from "this request is invalid": the message dead-lettered on its first attempt instead of being retried.
Add
platform/http.StatusError, a typed error that keeps the status code in the chain, andplatform/errs/http, the classifier that reads it. Server-state codes (500, 502, 503, 504, other 5xx, 429, 408) are retryable dependency errors; verdicts on the request (4xx, 3xx, the permanently broken 501 and 505, and a code that was never a response) are not.*url.Errorcovers transport failures, including an expired deadline — that means the remote end did not answer in time, so it is attributed to the dependency. Onlycontext.Canceledis declined, so a shutdown stays out of a backend's dependency metrics andplatform/errs/genericclaims that node. Nothing in the classifier depends onplatform/errs/mysqlbeing wired to reach a verdict; a test pins thegeneric+httpwiring a service with no MySQL dependency would use.The classifier must still be listed before
platform/errs/mysql, whosenet.Errorrule matches*url.Errorand would otherwise claim HTTP transport failures. Documented in the errs README next to the wiring example.StatusError.Errorrenders at most 1 KiB of the response body. The rendered string lands in the queue's dead-letter record viaReject(ctx, err.Error()), andlast_erroris a finite column, so an error page from a chatty gateway must not be able to fail that write and leave the message stuck rather than dead-lettered.Bodyitself is kept whole for callers that want to inspect it.Convert both build-runner clients — Buildkite and GitHub Actions — to return the typed error, and wire the classifier into the stovepipe server, which runs both. Client tests now assert the code is reachable with
errors.As, so a refactor back tofmt.Errorfcannot pass silently. The submitqueue-side clients (changeprovider/github,phabricator/conduit,mergechecker/github) are unchanged: no service wireshttperrson those paths, so nothing would read the code.Behavior change worth calling out: retried creates can duplicate a build
Creating a build is not idempotent, and a rejected create is now reported with its status code like any other, so a retried 502 can start a second build when the first was already accepted. Stovepipe's build controller has no guard against that —
request.State.IsTerminal()is false at the pointTriggerruns, and theErrAlreadyExiststolerance keys on a build ID the retry has not minted yet.This exposure is not new: a transport failure on the same call is already retryable today through the mysql classifier's
net.Errorrule, so a connection reset mid-write can already duplicate a build. This change widens it from transport failures to 5xx responses. The trade is deliberate — a request that gives up on a proxy blip strands its queue slot, which is worse — and both clients' create paths now document it. Making create idempotent is follow-up work and is the next branch.Why
Test Plan