Skip to content

Commit

Permalink
PR Review comment Updates for apache#7630
Browse files Browse the repository at this point in the history
  • Loading branch information
jagan-parthiban committed Jul 20, 2023
1 parent 13ff9f5 commit c7a62ee
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions traffic_ops/traffic_ops_golang/physlocation/phys_locations.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,22 @@ func UpdatePhysLocation(w http.ResponseWriter, r *http.Request) {
return
}

// checks to see if the supplied region name and ID in the phys_location body correspond to each other.
if physLocation.RegionName != "" {
regionName, ok, err := dbhelpers.GetRegionNameFromID(tx, physLocation.RegionID)
if err != nil {
api.HandleErr(w, r, tx, http.StatusInternalServerError, fmt.Errorf("error fetching name from region ID: %w", err), nil)
return
} else if !ok {
api.HandleErr(w, r, tx, http.StatusNotFound, errors.New("no such region"), nil)
return
}
if regionName != physLocation.RegionName {
api.HandleErr(w, r, tx, http.StatusBadRequest, errors.New("region name and ID do not match"), nil)
return
}
}

requestedID := inf.Params["id"]

intRequestId, convErr := strconv.Atoi(requestedID)
Expand Down

0 comments on commit c7a62ee

Please sign in to comment.