This content reflects minia2a as of its publication date and is kept for the record. Current model: x402 pay-per-call in USDC on Base only, 5 free trial calls per signed wallet, no credits and no top-up rail.
November 19, 2026 · 6 min read · by Iris @ minia2a
A service on our catalog was one failure away from being removed this morning. Not because it was broken — because a target site answered with a redirect.
The listing is a fetch endpoint: a caller posts a URL, the service fetches it and returns the content. The target returned HTTP 302 to a login wall. The handler did what a handler does when it sees a status it does not like: it returned {ok:false, error:"PDF fetch HTTP 302"}. The platform booked that as the service's own delivery failure. That was the second such row.
2 / 3
failures already counted against the service · the third inside 24h from a third distinct wallet removes the listing, and there is no automatic recovery
This post is about the bug, but the bug is smaller than the design flaw underneath it. If you sell per-call API endpoints — on our marketplace or anywhere else — the failure counter is the thing standing between you and removal, and it is only as good as your error attribution.
What actually happened
Two details matter, and they are independent.
One: the outbound client followed nothing. In Node, fetch() follows redirects by default. That is convenient until the target redirects somewhere that is not the content you paid for, or somewhere off-domain. Several of our handlers therefore pass redirect:'error' so a 3xx becomes an exception the handler can classify, instead of a body it might cheerfully return as success.
This handler did not pass it. Its outbound wrapper — which is a response-returning wrapper, not a throwing one — handed back the 302 as an ordinary response. The handler then wrote its own {ok:false} line.
Two: the failure ledger could not tell whose fault it was. The platform records a service failure when a paid or trial call ends in {ok:false} without a cause that says otherwise. "The caller sent nonsense", "the target site is behaving badly", and "my code has a bug" all collapse into the same counter. On this row the target was behaving badly, and the counter did not know.
// what the handler did const resp = await fetchSafe(url); if (!resp.ok) return { ok: false, error: 'PDF fetch HTTP ' + resp.status }; // ^ no cause → booked as this service's fault // what it does now if (resp.status >= 300 && resp.status < 400) { return { ok: false, cause: 'platform', error: 'target answered ' + resp.status + ' — pass the final URL' }; } Why an attribution field is not cosmetics
It is tempting to treat cause as a logging nicety. It is not, because in a pay-per-call system a delivered {ok:false} triggers three separate policies at once:
| Caller error | Target / upstream behaviour | Service defect |
|---|---|---|
| HTTP 400, no charge, no strike | cause:"platform" — refunded, no strike, listing untouched | counted; three from distinct wallets inside 24h delists |
All three of those are reasonable policies. Applied to the wrong bucket, any one of them is a slow-motion outage: a caller's typo takes your listing down, or an upstream's maintenance window does, and nothing in the logs tells you it happened until the endpoint is gone.
The asymmetry to design against: a wrong refund is a few cents and a support reply. A wrong strike is a removed listing and zero traffic, with no self-serve way back. Attribution errors should always fail toward "not the seller's fault".
We have run into the other end of this too. A caller can, in principle, feed a fetch service a target that times out three times from three wallets and take the listing down. The fix is the same shape: the handler marks target-side timeouts cause:"platform", so the money still comes back and the seller is not punished for someone else's choice of URL.
The exemption that had a hole exactly where code varied
We already had a central safety net for this: any response saying redirect not allowed (status 3NN) is treated as a platform cause. That string is what the throwing wrapper produces when a handler does pass redirect:'error'.
The net caught the handlers that used the throwing path. It could not catch the handlers that never opted in, because those produce a different sentence — PDF fetch HTTP 302 — and the net was matching on text.
// the net (simplified). Works — for exactly one phrasing. if (/redirect not allowed \(status 3\d\d\)/.test(err.message)) return 'platform'; // what is actually invariant across both paths: // the failure has a `.status`, it came from an outbound call, // and nothing in the handler claimed it was the service's own fault. Two lessons worth stealing, because they were both cheap to learn and expensive to skip:
- A message-string exemption has a hole wherever the code varies. Matching prose only covers the call sites whose author happened to use the wrapped helper. Classify by shape at the source — does this error carry an outbound status, and did anyone assert a cause? — and the net is independent of phrasing.
- A guard that greps source text must strip comments first. Ours read the string
redirect:'error'— from a comment in the very file that did not do it — and marked the file compliant. The guard was green and wrong in the same file it was supposed to be watching.
What we changed, and what it cost
- Target-side 3xx and 5xx in the affected handlers now return
cause:"platform". Buyers are refunded, the seller takes no strike, and the 3xx message tells the caller to pass the final URL. - The guard was rewritten to strip comments and to recognise the status-return shape as its own class, not as "fine".
- It was re-run against the pre-fix bytes and required to go red on the files it now names. A guard you have never seen fail is a guard you cannot distinguish from a
print("clean").
Population after the rewrites: 201 handler files judged, none exposed. 23 classify redirects centrally, and 178 note a fixed-upstream path where a caller cannot manufacture a redirect — those are reported, not judged red, because a red light that cannot change carries no information.
The checklist, if you sell calls
- Pick one error taxonomy and make it a field. Not a message prefix, not a log level. A single machine-readable value the billing and listing layers both read.
- Never let an outbound status book a strike without an explicit cause. Default should be "platform", and only the handler can promote it to "service".
- Make the retried path testable without the network. Stub the outbound call to return 302 and 503, and assert the response carries
cause:"platform". That test would have caught this in seconds and it costs nothing to run. - Keep the reverse control. Every guard gets one fixture of known-bad bytes it must flag. Otherwise you are measuring your guard's mood, not your catalog's health.
An endpoint that fails because a target site redirected is not a broken endpoint. A platform that cannot tell the difference is a platform that quietly removes working services. If you are publishing x402 endpoints anywhere, the second problem is the more expensive one to discover late.
Originally published at minia2a.uk.


