Credits limit growing without limit

It appears that our credit limits is growing indefinitely, not stopping at 2002. It’s currently at 101732972, which corresponds to almost 40 days at 30 credits per second.

The problem is that we’re currently trying to test our request throttling and handling “not enough credits” errors.

We can still trigger “not enough credits” error by making request with crazy high complexity. However, then “time_remaining” is 0:

curl --location --request GET 'https://public-api.shiphero.com/graphql' --header 'Content-Type: application/json' --header 'Authorization: Bearer {{ACCESS_TOKEN}}' --data '{"query":"query user_quota {\n  user_quota {\n    is_expired\n    expiration_date\n    time_remaining\n    credits_remaining\n    max_available\n    increment_rate\n  }\n}\n","variables":{}}'
{
    "data": {
        "user_quota": {
            "is_expired": false,
            "expiration_date": null,
            "time_remaining": null,
            "credits_remaining": 101733173,
            "max_available": 2002,
            "increment_rate": 30
        }
    },
    "extensions": {
        "throttling": {
            "estimated_complexity": 0,
            "cost": 1,
            "cost_detail": {
                "user_quota": {
                    "items_count": 0,
                    "cost": 1,
                    "total_cost": 1,
                    "fields": {}
                }
            },
            "user_quota": {
                "credits_remaining": 101733173,
                "max_available": 2002,
                "increment_rate": 30
            }
        }
    }
}

Hi @wkrsz

The time limit will depend mainly on the complexity of the query/mutation. You are given 2002 credits to begin with and recover 30 every second. If you spend more than 30 per second, you will eventually get the error.

The time_remaining is calculated =(required_credits - remaining_credits) / 30.
This is why it is giving 0.

Regarding the credits_remaining, that is something that is not correct. I tried reproducing in a staging environment, but I could not.
I’ll escalate this and will let you know.

Have a nice day!

Hi @wkrsz

A bug lets you recover over your stipulated maximum, which is not expected behavior. The credit limits have been adjusted and will stop in 2002.

Regarding the time_remaining being 0, it will always give 0 because you exceeded the max_available, so the code is not ready for that. In those cases, the time_remaining part of the code will be excluded.

Have a nice day!