Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST request to /api/4.0/phys_locations accepts mismatch values for regionName #5562 #6175

Closed
dmohan001c opened this issue Sep 8, 2021 · 2 comments · Fixed by #6269
Closed
Assignees
Labels
bug something isn't working as intended Traffic Ops related to Traffic Ops

Comments

@dmohan001c
Copy link
Contributor

dmohan001c commented Sep 8, 2021

I'm submitting a

  • Bug Report

This Bug Report affects these Traffic Control components:

  • Traffic Ops

Current behavior:

When you make a POST request to the /phys_locations endpoint, if you pass in the body with id from one Region and the name from another Region you get a successful response.

Expected behavior:

Request with a mismatch between Redion ID and name should fail or region could be dynamically named based on ID.

Minimal reproduction of the problem with instructions:

With these Regions in Traffic Ops

[
    {
        "divisionName": "Quebec",
        "division": 1,
        "id": 1,
        "lastUpdated": "2021-09-08 15:28:41+00",
        "name": "Montreal"
    },
    {
        "divisionName": "USA",
        "division": 2,
        "id": 2,
        "lastUpdated": "2021-09-08 15:28:41+00",
        "name": "Washington, D.C"
    }
]

Make a POST request to /phys_locations with this body:

{
    "address": "1234 mile high circle",
    "city": "Denver",
    "poc": "Person",
    "name": "Great_Britain1",
    "regionId": 1,
    "region": "Washington, D.C",
    "shortName": "testphyloc2",
    "state": "CO",
    "zip": "80202"
}

observe a 200 OK response that verifies the current state of the object is exactly what was submitted:

{
        "alerts": [
                {
                        "text": "physLocation was created.",
                        "level": "success"
                }
        ],
        "response": {
                "address": "1234 mile high circle",
                "city": "Denver",
                "comments": null,
                "email": null,
                "id": 3,
                "lastUpdated": "2021-09-08 15:49:36+00",
                "name": "Great_Britain1",
                "phone": null,
                "poc": "Person",
                "regionId": 1,
                "region": "Washington, D.C",
                "shortName": "testphyloc2",
                "state": "CO",
                "zip": "80202"
        }
}

... even though a subsequent GET request made to /phys_locations?id=3 shows that the Region name is different than what was submitted:

{
        "response": [
                {
                        "address": "1234 mile high circle",
                        "city": "Denver",
                        "comments": null,
                        "email": null,
                        "id": 3,
                        "lastUpdated": "2021-09-08 15:49:36+00",
                        "name": "Great_Britain1",
                        "phone": null,
                        "poc": "Person",
                        "regionId": 1,
                        "region": "Montreal",
                        "shortName": "testphyloc2",
                        "state": "CO",
                        "zip": "80202"
                }
        ]
}
@dmohan001c dmohan001c added the bug something isn't working as intended label Sep 8, 2021
@ocket8888
Copy link
Contributor

... or region could be dynamically named based on ID.

So instead of just ignoring the name it would correct it in the response to be the Region identified by regionId? IMO, it would be best to just do away with the ID in the requests and responses and just only use the name. Of course, that'll be a breaking API change whereas just correcting it wouldn't be.

@mitchell852 mitchell852 added the Traffic Ops related to Traffic Ops label Sep 29, 2021
@srijeet0406
Copy link
Contributor

I can take this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something isn't working as intended Traffic Ops related to Traffic Ops
Projects
None yet
4 participants