fix(x402scan): detect testnet-only origins and surface per-endpoint 422 detail - #769
Merged
bussyjd merged 1 commit intoJul 16, 2026
Merged
Conversation
…22 detail x402scan indexes mainnet resources only, but obol never inspected an offer's network before submitting, so a Base Sepolia origin that DID answer 402 got the generic "no endpoint answered with a live x402 402 challenge" — wrong and misleading. Add a local preflight that reads x-payment-info.accepts[].network from the origin's own /openapi.json and warns/explains when every advertised network is a known testnet. Also fix an asymmetry in internal/x402scan/client.go: the 422 (no_valid_resources) rejection path decoded only a flat error message, silently dropping the same per-endpoint failedDetails the 200-partial- failure path already surfaces. registryError now carries FailedDetails too, so per-endpoint probe failures show up on both paths. Addresses a Canary402 field report. Claude-Session: https://claude.ai/code/session_014YjPMViNrZ7zBVgUQzwEKk
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.
Canary402 field report — issues 0/10 (x402scan rejects testnet resources with a misleading generic message)
x402scan indexes mainnet resources only; registering an origin whose offers price on Base Sepolia failed with x402scan's generic "no valid paid resources", which obol relayed as "no endpoint answered with a live x402 402 challenge" — factually wrong (the endpoints answered 402 fine) and pointing the operator away from the real cause. Per-endpoint failure detail returned by the registry on the 422 path was also silently dropped.
Fix
internal/x402/chains.go:Testnetflag on the existing chain registry +IsTestnetCAIP2helper (single source of truth, no second hardcoded list).preflightOpenAPI) decodesx-payment-info.accepts[].networkacross paid paths; when every network is a testnet it warns before submitting, and theErrNoValidResourcesfailure message becomes an accurate "offers price on (testnet) — x402scan indexes mainnet resources only; switch payment network to a mainnet and re-register" (generic text kept as fallback for genuinely-no-402 cases).internal/x402scan/client.go: the 422 error path now carriesfailedDetails(per-endpoint url/error/status), symmetric with the 200 partial-failure path.Tests: golden-fixture 422-with-failedDetails, testnet-detection preflight test, chains table test.
go test ./cmd/obol/... ./internal/x402/... ./internal/x402scan/...green.Part of the Canary402 field-report sweep (6 PRs). Commit unsigned — batch re-sign before merge if required.
https://claude.ai/code/session_014YjPMViNrZ7zBVgUQzwEKk