这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@ZIMkaRU
Copy link
Member

@ZIMkaRU ZIMkaRU commented Jun 21, 2023

This PR prevents proxying all HTML of the bfx api error


In some cases, the bfx api may respond just HTML instead of expected json in the raw body https://github.com/bitfinexcom/bfx-api-node-rest/blame/master/lib/rest2.js#L166
For example: maintenance mode, nginx 502 Bad Gateway error, 403 Forbidden for the staging server, check the screenshot:

Screenshot from 2023-06-16 14-32-19-123


The idea is:

  • don't proxy all HTML
  • extract a string of the title tag to use as a description of the error
  • and pass it to the corresponding field of an error

Basic changes:

  • Prevents proxying all HTML of bfx api error
  • Adds forbidden resource error tester
  • Handles forbidden resource error
  • Adds test cases for response service for handling error with html and plain text in the response body

Request example:

{
  "auth": {
    "apiKey": "api_key",
    "apiSecret": "api_secret"
  },
  "method": "verifyUser"
}

Response example:

{
  "jsonrpc": "2.0",
  "error": {
    "code": 403,
    "message": "Forbidden",
    "data": {
      "bfxApiErrorMessage": {
        "bfxApiStatus": 403,
        "bfxApiStatusText": "Forbidden",
        "bfxApiRawBodyCode": "Code is not abailable",
        "isBfxApiRawBodyResponseHtml": "Yes",
        "bfxApiRawBodyResponse": "Access denied | api.staging.bitfinex.com used Cloudflare to restrict access"
      }
    }
  },
  "id": null
}

Error logging examples:

Screenshot from 2023-06-20 08-52-46

Screenshot from 2023-06-21 08-27-57

Copy link
Contributor

@ezewer ezewer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

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.

3 participants