Skip to content

Conversation

@fmhall
Copy link
Contributor

@fmhall fmhall commented Jan 12, 2026

PR: Improve Resource Sync Route Reliability & Use Official x402 SDK

Summary

Refactors the /api/resources/sync endpoint to use the official @x402/core and @x402/extensions packages for facilitator discovery, improves error handling, and adds safeguards against malformed facilitator data.

Changes

Sync Route Improvements

  • Migrated from custom facilitator fetching logic to official HTTPFacilitatorClient and withBazaar extension from @x402/extensions
  • Added skip query parameter to exclude specific facilitators (e.g., ?skip=coinbase)
  • Added resourcesSkipReasons to response for better observability into why resources are skipped
  • Reduced cron frequency from every 1 minute to every 10 minutes

Schema Validation Hardening

  • Added .refine() validation on maxAmountRequired to ensure it's a valid numeric string before BigInt conversion
  • Prevents sync endpoint crashes when facilitators return malformed data (e.g., "invalid", "N/A", empty strings)

Dependencies

  • Added @x402/core@^2.2.0 and @x402/extensions@^2.2.0

Why

  • The previous implementation could crash the entire sync operation if any facilitator returned an accepts entry with an invalid maxAmountRequired value
  • Using the official SDK simplifies the codebase and ensures compatibility with the x402 spec
  • The skip parameter allows us to temporarily exclude problematic facilitators (like Coinbase which has aggressive rate limits) without code changes

@vercel
Copy link
Contributor

vercel bot commented Jan 12, 2026

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

Project Deployment Review Updated (UTC)
x402scan Ready Ready Preview, Comment Jan 12, 2026 5:52pm

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.

2 participants