You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every error is now JSON { code, message, nextAction, docs } with a stable
`code` field agents can branch on. Three failure modes are caught BEFORE
paymentMiddleware so agents are never charged USDC for guaranteed-failure
requests:
- UNKNOWN_TIER (404) — path tier not 1day|7days|30days
- MISSING_SENTINEL_ADDR (400) — body lacks sentinelAddr
- INVALID_SENTINEL_ADDR (400) — sentinelAddr doesn't match sent1-bech32 regex
Replaces Express's default HTML 404 with a JSON catch-all (NOT_FOUND), and
adds a final error handler so any uncaught exception still renders as
structured JSON (INTERNAL_ERROR).
/manifest.response.errors now publishes the full code table; docs/llms.txt
adds an Errors section mirroring it.
Verified locally with curl probes — all four error modes return structured
JSON; valid requests still flow through paymentMiddleware to HTTP 402.
Copy file name to clipboardExpand all lines: docs/llms.txt
+14Lines changed: 14 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -125,6 +125,20 @@ const vpn = await connect({
125
125
}
126
126
```
127
127
128
+
## Errors
129
+
130
+
All errors are JSON `{ code, message, nextAction, docs }`. Branch on `code` — it is the stable contract. The first three are returned **before** payment is taken, so agents are never charged USDC for a guaranteed-failure request.
131
+
132
+
| `code` | Status | Pre-payment | Meaning |
133
+
|---|---|---|---|
134
+
| `MISSING_SENTINEL_ADDR` | 400 | yes | Body did not include `sentinelAddr`. |
135
+
| `INVALID_SENTINEL_ADDR` | 400 | yes | `sentinelAddr` does not match `^sent1[0-9a-z]{38}$`. Use `createWallet()` from `blue-js-sdk/ai-path`. |
136
+
| `UNKNOWN_TIER` | 404 | yes | Path tier is not `1day` \| `7days` \| `30days`. |
137
+
| `PAYMENT_REQUIRED` | 402 | — | Sign EIP-3009 `transferWithAuthorization` and resend with the `PAYMENT-SIGNATURE` header. `@x402/fetch` handles this automatically. |
note: 'All errors are JSON: { code, message, nextAction, docs }. Branch on `code` — it is the stable contract.',
358
+
codes: {
359
+
MISSING_SENTINEL_ADDR: {status: 400,meaning: 'Request body did not include sentinelAddr.'},
360
+
INVALID_SENTINEL_ADDR: {status: 400,meaning: "sentinelAddr is not a valid sent1-bech32 address — use createWallet() from 'blue-js-sdk/ai-path'."},
361
+
UNKNOWN_TIER: {status: 404,meaning: 'Path tier is not one of 1day | 7days | 30days.'},
362
+
PAYMENT_REQUIRED: {status: 402,meaning: 'Sign EIP-3009 transferWithAuthorization and resend with PAYMENT-SIGNATURE header. @x402/fetch handles this automatically.'},
363
+
PROVISIONING_FAILED: {status: 500,meaning: 'Payment settled but Sentinel TX failed. Safe to retry once; EIP-3009 nonce prevents double-charge.'},
364
+
INTERNAL_ERROR: {status: 500,meaning: 'Unexpected server error. Open an issue if reproducible.'},
365
+
NOT_FOUND: {status: 404,meaning: 'No route matches. See /manifest for endpoints.'},
366
+
},
367
+
prePaymentGuarantee: 'MISSING_SENTINEL_ADDR / INVALID_SENTINEL_ADDR / UNKNOWN_TIER are returned BEFORE paymentMiddleware. Agents are never charged USDC for guaranteed-failure requests.',
0 commit comments