stellar/go

Fix how non-2xx codes are returned by `async-txsub` endpoint

aditya1702 opened this issue · 0 comments

Epic: #5433

For AsyncSubmitTransactionXDR, if the user passes in an invalid XDR, the data returned by Horizon is as follows:

{
  "type": "https://stellar.org/horizon-errors/transaction_malformed",
  "title": "Transaction Malformed",
  "status": 400,
  "detail": "Horizon could not decode the transaction envelope in this request. A transaction should be an XDR TransactionEnvelope struct encoded using base64.  The envelope read from this request is echoed in the `extras.envelope_xdr` field of this response for your convenience.",
  "extras": {
    "envelope_xdr": "AAAAAgAAAAAoXi7Kz8/PAl9GZl5AD09H080g961ptb1MMfj6evUsJwAAAGQACuJqAAAAEQAAAAEAAAAAAAAAAAAAAABmoxT9AAAAAQAAAA9IZWxsbywgU3RlbGxhciEAAAAAAQAAAAAAAAABAAAAAPSbkKYju7E2GtKbpAnQ0twJCAGBwIcxea690WueeVSjAAAAAAAAAADQsJmHAAAAAAAAAAF69SwnAAAAQHgHTIiwgcIvdm0//yTH9o9rsGlMCng7YjKrOszNaJ0qwvPeLs8/bNdTRdg51gs3/RQAhT4lDeJR4Bs5wgZjeMgM=",
    "error": {}
  }
}

However, due to this change, the error returned by AsyncSubmitTransactionXDR will be nil, which does not meet expectations.

For non-2xx status codes, Horizon returns responses in a format similar to the one above. The transactions_async endpoint is an exception to this.

What needs to be done

Change the return format so that horizon.Problem responses returned by the async endpoint can be mapped to a valid error