Skip to content

Skip OpenAPI-declared non-paid endpoints instead of probing them#837

Open
fmhall wants to merge 1 commit into
mainfrom
mason/skip-unauthed-openapi-resources
Open

Skip OpenAPI-declared non-paid endpoints instead of probing them#837
fmhall wants to merge 1 commit into
mainfrom
mason/skip-unauthed-openapi-resources

Conversation

@fmhall
Copy link
Copy Markdown
Member

@fmhall fmhall commented May 5, 2026

Summary

  • When discovery source is openapi and a route's authMode is anything other than paid or apiKey+paid (and isn't already short-circuited as siwx), report it as skipped instead of probing.
  • Stops false-positive failed: "No valid x402 response found" for OpenAPI-declared free/public endpoints (e.g. GET /api/site/domain/preview on stableupload.dev).
  • Well-known/x402 v1 omits authMode entirely, so well-known sources still fall through to the probe — no behavior change there.

Why

Per "OpenAPI is canonical": if the spec has no x-payment-info and no paid security scheme, the route is authoritatively not an x402 paid endpoint. The probe will correctly find no 402 challenge — but x402scan currently treats that as a failure rather than a confirmation. This patch trusts the spec.

Verification (local)

Origin Source Result
stableupload.dev openapi registered=3 siwx=7 skipped=1 failed=0 (prod was failed=4)
agentcash.honcho.dev openapi registered=2 siwx=14 skipped=0 failed=0 (no regression)
stableenrich.dev openapi registered=33 siwx=1 skipped=0 failed=0 (no regression)

Reproduce with pnpm tsx src/scripts/verify-discovery-gate.ts <origin>.

Test plan

  • Deploy to preview
  • POST /api/x402/registry/register-origin with {"origin":"https://stableupload.dev"}failed: 0, skipped: 1 (/api/site/domain/preview)
  • Re-register agentcash.honcho.dev and stableenrich.dev; counts unchanged
  • Quick smoke against a well-known/x402 origin to confirm we still probe when source !== 'openapi'
  • Promote to prod

🤖 Generated with Claude Code

When an OpenAPI spec is canonical, the inferred authMode is the truth: a
route without `x-payment-info` and without a paid security scheme is not
an x402 paid endpoint and shouldn't be probed at all. Today we probe
those routes anyway and report them as `failed: "No valid x402 response
found"`, which surfaces as a false-positive failure for any origin whose
OpenAPI exposes a public/free helper endpoint (seen on stableupload.dev's
GET /api/site/domain/preview).

When source === 'openapi' and authMode is anything other than `paid` or
`apiKey+paid` (and the siwx short-circuit didn't already handle it),
return the resource as `skipped` with a clear reason. Well-known/x402 v1
omits authMode and still falls through to the probe.

Verified locally:
  stableupload.dev    registered=3 siwx=7 skipped=1 failed=0  (was failed=4)
  agentcash.honcho.dev registered=2 siwx=14 skipped=0 failed=0  (no regression)
  stableenrich.dev    registered=33 siwx=1 skipped=0 failed=0  (no regression)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
x402scan Ready Ready Preview, Comment May 5, 2026 10:57pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant