XRPLF / clio

An XRP Ledger API Server
https://xrpl.org
ISC License
56 stars 48 forks source link

[get_aggregate_price] with malformed base_asset value returns different error on Clio compared to rippled #1372

Closed mounikakun closed 1 week ago

mounikakun commented 2 months ago

Issue Description

Clio returns invalidParams whereas rippled returns objectNotFound with malformed base_asset values in get_aggregate_price

Steps to Reproduce

Request:


{
  "method": "get_aggregate_price",
  "params": [
    {
      "base_asset": 123,
      "quote_asset": "ETH",
      "oracles": [
        {
          "account": "rwz8i5bUKa12tYxQjsSuzDQaBwKkuGUqa5",
          "oracle_document_id": 1
        },
        {
          "account": "rDtBhKmzKveCSd5jmrcQD6CU8kidCLCy7h",
          "oracle_document_id": 1
        }
      ]
    }
  ]
}

Expected Result

Rippled response:

{
    "result": {
        "error": "objectNotFound",
        "error_code": 92,
        "error_message": "The requested object was not found.",
        "ledger_current_index": 82290,
        "request": {
            "base_asset": 123,
            "command": "get_aggregate_price",
            "oracles": [
                {
                    "account": "rwz8i5bUKa12tYxQjsSuzDQaBwKkuGUqa5",
                    "oracle_document_id": 1
                },
                {
                    "account": "rDtBhKmzKveCSd5jmrcQD6CU8kidCLCy7h",
                    "oracle_document_id": 1
                }
            ],
            "quote_asset": "ETH"
        },
        "status": "error",
        "validated": false
    }
}

Actual Result

Clio response:

{
    "result": {
        "error": "invalidParams",
        "error_code": 31,
        "error_message": "Invalid parameters.",
        "status": "error",
        "type": "response",
        "request": {
            "method": "get_aggregate_price",
            "params": [
                {
                    "base_asset": 123,
                    "quote_asset": "ETH",
                    "oracles": [
                        {
                            "account": "rwz8i5bUKa12tYxQjsSuzDQaBwKkuGUqa5",
                            "oracle_document_id": 1
                        },
                        {
                            "account": "rDtBhKmzKveCSd5jmrcQD6CU8kidCLCy7h",
                            "oracle_document_id": 1
                        }
                    ]
                }
            ]
        }
    },
    "warnings": [
        {
            "id": 2001,
            "message": "This is a clio server. clio only serves validated data. If you want to talk to rippled, include 'ledger_index':'current' in your request"
        }
    ]
}

Environment

Supporting Files

cindyyan317 commented 2 months ago

I think Clio's response (invalidParams) maybe more descriptive.

mounikakun commented 1 month ago

Issue is fixed on rippled end for the below invalid test data.

None, "Invalid", 123, -1, 0, 1.2,  "H", "HB", "HBAR", "", _INVALID_NON_STANDARD_CURRENCY_CODE_:"0158415500000000C1F76FF6ECB0BAC600000000A"

objectNotFound remains same for the below cases

VALID_NON_STANDARD_CURRENCY_CODE = "0158415500000000C1F76FF6ECB0BAC600000000", "HBA"

mounikakun commented 1 month ago

Clio is not replicating invalidParams error for below test data

"Invalid", _INVALID_NON_STANDARD_CURRENCY_CODE_:"0158415500000000C1F76FF6ECB0BAC600000000A", "H", "HB", "HBAR", ""

mounikakun commented 1 week ago

Issue still exists for empty "" values of base_asset

empty base_asset request:

{"method": "get_aggregate_price", "params": [{"base_asset": "", "quote_asset": "ETH", "oracles": [{"account": "rDvpETjjxp4KH6RzyMBCHkxs6p9y7taecG", "oracle_document_id": 1}, {"account": "rNpPJMYRmnfVNUgXv6X1pn93WkNzchNwnS", "oracle_document_id": 1}], "Fee": "20"}]}

rippled response:

{
    "result": {
        "error": "invalidParams",
        "error_code": 31,
        "error_message": "Invalid parameters.",
        "request": {
            "Fee": "20",
            "base_asset": "",
            "command": "get_aggregate_price",
            "oracles": [
                {
                    "account": "rDvpETjjxp4KH6RzyMBCHkxs6p9y7taecG",
                    "oracle_document_id": 1
                },
                {
                    "account": "rNpPJMYRmnfVNUgXv6X1pn93WkNzchNwnS",
                    "oracle_document_id": 1
                }
            ],
            "quote_asset": "ETH"
        },
        "status": "error"
    }
}

clio response:

{
    "result": {
        "error": "objectNotFound",
        "error_code": 92,
        "error_message": "The requested object was not found.",
        "status": "error",
        "type": "response",
        "request": {
            "method": "get_aggregate_price",
            "params": [
                {
                    "base_asset": "",
                    "quote_asset": "ETH",
                    "oracles": [
                        {
                            "account": "rDvpETjjxp4KH6RzyMBCHkxs6p9y7taecG",
                            "oracle_document_id": 1
                        },
                        {
                            "account": "rNpPJMYRmnfVNUgXv6X1pn93WkNzchNwnS",
                            "oracle_document_id": 1
                        }
                    ],
                    "Fee": "20"
                }
            ]
        }
    },
    "warnings": [
        {
            "id": 2001,
            "message": "This is a clio server. clio only serves validated data. If you want to talk to rippled, include 'ledger_index':'current' in your request"
        }
    ]
}
cindyyan317 commented 1 week ago

Fixed by #1481