apache / trafficcontrol

Apache Traffic Control is an Open Source implementation of a Content Delivery Network
https://trafficcontrol.apache.org/
Apache License 2.0
1.06k stars 340 forks source link

Internal Server Error when /GET asns API with cachegroup query parameter #5021

Open dpham692 opened 3 years ago

dpham692 commented 3 years ago

I'm submitting a ...

Traffic Control components affected ...

Current behavior:

Perform a /GET https://{{TO_BASE_URL}}/api/3.0/asns?cachegroup={{cachegroupName}} API will return Status Code 500

{
    "alerts": [
        {
            "text": "Internal Server Error",
            "level": "error"
        }
    ]
}

Expected / new behavior:

API should return correct ASNs that link with the cache group.

Minimal reproduction of the problem with instructions:

Anything else:

srijeet0406 commented 3 years ago

This is expected behavior. When you search by cachegroup name, you need to use cachegroupName as the query param. If you want to use cachegroup ID, use cachegroup. So the following two calls should work: GET /api/3.0/asns?cachegroupName=<your cg name here> and GET /api/3.0/asns?cachegroup=<your cg ID here>.

I spoke to @dpham692 and he was ok with closing this issue.

zrhoffman commented 3 years ago

Since the cachegroup query parameter should be an ID, it should be validated and return 400 bad request instead of 500 internal server error when the user provides a string.