interledger / rafiki

An open-source, comprehensive Interledger service for wallet providers, enabling them to provide Interledger functionality to their users.
https://rafiki.dev/
Apache License 2.0
260 stars 89 forks source link

[BUG] Internal Server Error when creating a quote for a wallet address that exists in another ILP allocation scheme #3093

Open raducristianpopa opened 6 days ago

raducristianpopa commented 6 days ago

Bug Report

Describe the bug

When we attempt to create a quote for a wallet address that lives in another Rafiki instances, Internal Server Error is returned.

My initial thought: this is happening because of the ILP addresses. One being on the global allocation scheme and one being on the test allocation scheme.

To Reproduce

Steps and commands to reproduce the behavior. Please provide clear code snippets that always reproduce the bug.

  1. Create a quote from wallet.interledger-test.dev to ilp.dev

Expected behavior

Return a proper error message that signals why the quote creation failed.

Additional context

{"level":30,"time":1731067771813,"pid":1,"hostname":"rafiki-backend-test-5657cc6555-lnhdg","service":"ConnectorService","err":{"type":"UnreachableError","message":"unknown destination account","stack":"Error: unknown destination account\n    at account (/home/rafiki/packages/backend/dist/payment-method/ilp/connector/core/middleware/account.js:87:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async /home/rafiki/packages/backend/dist/payment-method/ilp/connector/core/middleware/stream-address.js:9:9\n    at async /home/rafiki/packages/backend/dist/payment-method/ilp/connector/core/middleware/error-handler.js:14:13\n    at async Rafiki.handleIlpData (/home/rafiki/packages/backend/dist/payment-method/ilp/connector/core/rafiki.js:57:9)\n    at async RateProbe.sendRequest (/home/rafiki/node_modules/.pnpm/@interledger+pay@0.4.0-alpha.9/node_modules/@interledger/pay/dist/src/request.js:57:26)","ilpErrorCode":"F02"},"msg":"Error thrown in incoming pipeline"}
{"level":50,"time":1731067771814,"pid":1,"hostname":"rafiki-backend-test-5657cc6555-lnhdg","service":"IlpPaymentService","err":"ConnectorError","msg":"Received error during ILP quoting"}
{"level":50,"time":1731067771816,"pid":1,"hostname":"rafiki-backend-test-5657cc6555-lnhdg","service":"ConnectorService","destinationAddress":"g.cards.TGBkfHkIAwC6oEzQhy-BnAr8zeV1i5KHBdGjL35zgoFzuY3VHBlw6jttFkiYXEu2pb2LaFy1V9rL28LjVd_F9CeJRaXb2yk","msg":"unknown destination account"}

  InternalServerError: Internal Server Error
      at Object.throw (/home/rafiki/node_modules/.pnpm/koa@2.15.2/node_modules/koa/lib/context.js:97:11)
      at openPaymentsServerErrorMiddleware (/home/rafiki/packages/backend/dist/open_payments/route-errors.js:53:18)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async bodyParser (/home/rafiki/node_modules/.pnpm/koa-bodyparser@4.4.1/node_modules/koa-bodyparser/index.js:78:5)
      at async cors (/home/rafiki/node_modules/.pnpm/@koa+cors@5.0.0/node_modules/@koa/cors/index.js:109:16)

{"level":30,"time":1731067771816,"pid":1,"hostname":"rafiki-backend-test-5657cc6555-lnhdg","service":"ConnectorService","err":{"type":"UnreachableError","message":"unknown destination account","stack":"Error: unknown destination account\n    at account (/home/rafiki/packages/backend/dist/payment-method/ilp/connector/core/middleware/account.js:87:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async /home/rafiki/packages/backend/dist/payment-method/ilp/connector/core/middleware/stream-address.js:9:9\n    at async /home/rafiki/packages/backend/dist/payment-method/ilp/connector/core/middleware/error-handler.js:14:13\n    at async Rafiki.handleIlpData (/home/rafiki/packages/backend/dist/payment-method/ilp/connector/core/rafiki.js:57:9)\n    at async ConnectionCloser.sendRequest (/home/rafiki/node_modules/.pnpm/@interledger+pay@0.4.0-alpha.9/node_modules/@interledger/pay/dist/src/request.js:57:26)","ilpErrorCode":"F02"},"msg":"Error thrown in incoming pipeline"}
{"level":50,"time":1731067771816,"pid":1,"hostname":"rafiki-backend-test-5657cc6555-lnhdg","service":"QuoteService","err":{"type":"PaymentMethodHandlerError","message":"Received error during ILP quoting","stack":"PaymentMethodHandlerError: Received error during ILP quoting\n    at getQuote (/home/rafiki/packages/backend/dist/payment-method/ilp/service.js:84:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async createQuote (/home/rafiki/packages/backend/dist/open_payments/quote/service.js:51:23)\n    at async createOutgoingPayment (/home/rafiki/packages/backend/dist/open_payments/payment/outgoing/service.js:118:30)\n    at async createOutgoingPayment (/home/rafiki/packages/backend/dist/open_payments/payment/outgoing/routes.js:62:36)\n    at async getWalletAddressForSubresource (/home/rafiki/packages/backend/dist/open_payments/wallet_address/middleware.js:72:5)\n    at async httpsigMiddleware (/home/rafiki/packages/backend/dist/open_payments/auth/middleware.js:165:5)\n    at async /home/rafiki/packages/backend/dist/open_payments/auth/middleware.js:94:9\n    at async getWalletAddressUrlFromRequestBody (/home/rafiki/packages/backend/dist/open_payments/wallet_address/middleware.js:7:5)\n    at async /home/rafiki/node_modules/.pnpm/@interledger+openapi@2.0.1/node_modules/@interledger/openapi/dist/middleware.js:27:9","name":"PaymentMethodHandlerError","description":"ConnectorError","retryable":true},"msg":"error creating a quote"}
{"level":50,"time":1731067771817,"pid":1,"hostname":"rafiki-backend-test-5657cc6555-lnhdg","method":"POST","path":"/outgoing-payments","err":{"type":"PaymentMethodHandlerError","message":"Received error during ILP quoting","stack":"PaymentMethodHandlerError: Received error during ILP quoting\n    at getQuote (/home/rafiki/packages/backend/dist/payment-method/ilp/service.js:84:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async createQuote (/home/rafiki/packages/backend/dist/open_payments/quote/service.js:51:23)\n    at async createOutgoingPayment (/home/rafiki/packages/backend/dist/open_payments/payment/outgoing/service.js:118:30)\n    at async createOutgoingPayment (/home/rafiki/packages/backend/dist/open_payments/payment/outgoing/routes.js:62:36)\n    at async getWalletAddressForSubresource (/home/rafiki/packages/backend/dist/open_payments/wallet_address/middleware.js:72:5)\n    at async httpsigMiddleware (/home/rafiki/packages/backend/dist/open_payments/auth/middleware.js:165:5)\n    at async /home/rafiki/packages/backend/dist/open_payments/auth/middleware.js:94:9\n    at async getWalletAddressUrlFromRequestBody (/home/rafiki/packages/backend/dist/open_payments/wallet_address/middleware.js:7:5)\n    at async /home/rafiki/node_modules/.pnpm/@interledger+openapi@2.0.1/node_modules/@interledger/openapi/dist/middleware.js:27:9","name":"PaymentMethodHandlerError","description":"ConnectorError","retryable":true},"msg":"Received unhandled error in Open Payments request"}
fetch("https://ilp.interledger-test.dev/quotes", {
  "headers": {
    "accept": "application/json",
    "accept-language": "en-GB,en-US;q=0.9,en;q=0.8",
    "authorization": "<redacted>",
    "cache-control": "no-cache",
    "content-digest": "<redacted>",
    "content-type": "application/json",
    "pragma": "no-cache",
    "priority": "u=1, i",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "none",
    "signature": "<redacted>"
  },
  "referrerPolicy": "strict-origin-when-cross-origin",
  "body": "{\"method\":\"ilp\",\"receiver\":\"https://ilp.interledger.cards/incoming-payments/7c5c7356-613d-462e-a7df-dd44c510420e\",\"walletAddress\":\"https://ilp.interledger-test.dev/radu-usd\",\"debitAmount\":{\"value\":\"1\",\"assetCode\":\"USD\",\"assetScale\":2}}",
  "method": "POST"
});
mkurapov commented 2 days ago

We should be able to reproduce this in the local playground by making the ilp addresses of one of the MASE's to something that is not the test allocation scheme.