x402
x402 copied to clipboard
Dirty data causes an pydantic error
By using the python discover API
from x402.facilitator import FacilitatorClient, FacilitatorConfig
from cdp.x402 import create_facilitator_config
# Set up facilitator client
facilitator_config = create_facilitator_config()
facilitator = FacilitatorClient(facilitator_config)
# Fetch all available services
services = await facilitator.list()
I got this error
pydantic_core._pydantic_core.ValidationError: 1 validation error for ListDiscoveryResourcesResponse
items.41.accepts.0.maxAmountRequired
Value error, max_amount_required must be an integer encoded as a string [type=value_error, input_value='', input_type=str]
After I changed some source code, I found the original data:
DiscoveredResource(resource='https://ai-api-sbx.aeon.xyz/open/ai/402/payment', type='http', x402_version=1, accepts=[PaymentRequirements(scheme='exact', network='base', max_amount_required='', resource='https://ai-api-sbx.aeon.xyz/open/ai/402/payment', description='Fiat QR code payment, only supports dynamic QR codes with amounts, supports country VND, PHP, BRL, GEL.', mime_type='', output_schema={'input': {'discoverable': True, 'method': 'GET', 'query_params': {'address': 'Ethereum address to receive payment', 'appId': 'Application ID for identifying request source(此项不是必须填写的)', 'qrCode': 'QR code data containing payment information'}, 'type': 'http'}, 'output': {'properties': {'code': {'description': 'response', 'type': 'string'}, 'model': {'description': 'order info', 'properties': {'bankData': {'description': 'Bank information', 'properties': {'bankAccountName': {'description': 'Bank account name', 'type': 'string'}, 'bankAccountNumber': {'description': 'Bank account number', 'type': 'string'}, 'bankCode': {'description': 'Bank code', 'type': 'string'}, 'bankName': {'description': 'Bank name', 'type': 'string'}}, 'type': 'object'}, 'createTime': {'description': 'Transaction creation time', 'type': 'string'}, 'fiatExchangeRate': {'description': 'Fiat exchange rate', 'type': 'string'}, 'merchantOrderNo': {'description': 'Merchant order number', 'type': 'string'}, 'num': {'description': 'System order number', 'type': 'string'}, 'orderAmount': {'description': 'Fiat currency amount', 'type': 'string'}, 'orderCurrency': {'description': 'Order fiat currency', 'type': 'string'}, 'qrCode': {'description': 'QR code', 'type': 'string'}, 'status': {'description': 'Order status', 'type': 'string'}, 'usdAmount': {'description': 'USD amount', 'type': 'string'}}, 'type': 'object'}, 'msg': {'description': 'response message', 'type': 'string'}, 'traceId': '68a80e45a29409f967801114b44ebfc6'}, 'type': 'object'}}, pay_to='', max_timeout_seconds=60, asset='0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', extra={'name': 'USD Coin', 'version': '2'})], last_updated=datetime.datetime(2025, 11, 4, 1, 51, 31, 823000, tzinfo=TzInfo(0)), metadata={'confidence': {'overallScore': 0.72, 'performanceScore': 0.92, 'recencyScore': 0.05, 'reliabilityScore': 1, 'volumeScore': 0.2}, 'errorAnalysis': {'abandonedFlows': 0, 'apiErrors': 0, 'delayedSettlements': 0, 'facilitatorErrors': 0, 'requestErrors': 2}, 'paymentAnalytics': {'averageDailyTransactions': 0, 'base:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913': 14900000, 'totalTransactions': 2, 'totalUniqueUsers': 1, 'transactions24h': 0, 'transactionsMonth': 0, 'transactionsWeek': 0}, 'performance': {'avgLatencyMs': 2639, 'maxLatencyMs': 3708, 'minLatencyMs': 1571, 'recentAvgLatencyMs': 2639}, 'reliability': {'apiSuccessRate': 1, 'successfulSettlements': 2, 'totalRequests': 2}})
The 'max_amount_required' is empty here, which cause the error above. I think either request the data to not be empty or update the "max_amount_required" validate method could solve this bug
Should this be fixed by allowing empty string, or is this a data quality issue that aeon.xyz needs to fix on their end? @phdargen