srijeet0406 commented on a change in pull request #5480:
URL: https://github.com/apache/trafficcontrol/pull/5480#discussion_r566373860
##########
File path:
traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices_test.go
##########
@@ -70,6 +70,9 @@ func TestGetDetails(t *testing.T) {
if oldDetails.OldCdnName != "foo" {
t.Errorf("expected old cdn name to be foo, but got %v",
oldDetails.OldCdnName)
}
+ if *oldDetails.OldCdnId != 1 {
Review comment:
You need to add a `nil` check for `oldDetails.OldCdnId` here. Basically
something like is being done in line 61.
##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -862,8 +863,8 @@ func updateV31(w http.ResponseWriter, r *http.Request, inf
*api.APIInfo, dsV31 *
if err != nil {
return nil, http.StatusInternalServerError, nil,
fmt.Errorf("querying delivery service with sslKeyVersion failed: %s", err)
}
- if ds.CDNName != nil && ds.RoutingName != nil {
- if sslKeysExist && (oldDetails.OldCdnName !=
*ds.CDNName || oldDetails.OldRoutingName != *ds.RoutingName) {
+ if (ds.CDNName != nil || ds.CDNID != nil) && ds.RoutingName !=
nil {
+ if sslKeysExist && (*oldDetails.OldCdnId != *ds.CDNID
|| oldDetails.OldCdnName != *ds.CDNName || oldDetails.OldRoutingName !=
*ds.RoutingName) {
Review comment:
If `oldDetails.OldCdnId` is `nil`, this will seg fault here.
##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -862,8 +863,8 @@ func updateV31(w http.ResponseWriter, r *http.Request, inf
*api.APIInfo, dsV31 *
if err != nil {
return nil, http.StatusInternalServerError, nil,
fmt.Errorf("querying delivery service with sslKeyVersion failed: %s", err)
}
- if ds.CDNName != nil && ds.RoutingName != nil {
- if sslKeysExist && (oldDetails.OldCdnName !=
*ds.CDNName || oldDetails.OldRoutingName != *ds.RoutingName) {
+ if (ds.CDNName != nil || ds.CDNID != nil) && ds.RoutingName !=
nil {
Review comment:
If one of ds.CDNName or ds.CDNID is nil, this will cause the next line
to seg fault
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]