This is an automated email from the ASF dual-hosted git repository.

rob pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new a4efce3  Fixes internal server error for 
`cachegroups/:id/queue_update` blank field (#3442)
a4efce3 is described below

commit a4efce3a1b010335ae67ab05c751304972507214
Author: Matthew Allen Moltzau <[email protected]>
AuthorDate: Mon Apr 29 12:05:04 2019 -0600

    Fixes internal server error for `cachegroups/:id/queue_update` blank field 
(#3442)
    
    * Fixes #2933
    
    Also adds error message for when cdn is blank.
    
    * Updated according to PR comments to catch more nil cases
---
 traffic_ops/traffic_ops_golang/cachegroup/queueupdate.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/traffic_ops/traffic_ops_golang/cachegroup/queueupdate.go 
b/traffic_ops/traffic_ops_golang/cachegroup/queueupdate.go
index 5b8e398..6a4a478 100644
--- a/traffic_ops/traffic_ops_golang/cachegroup/queueupdate.go
+++ b/traffic_ops/traffic_ops_golang/cachegroup/queueupdate.go
@@ -48,11 +48,11 @@ func QueueUpdates(w http.ResponseWriter, r *http.Request) {
                api.HandleErr(w, r, inf.Tx.Tx, http.StatusBadRequest, 
errors.New("action must be 'queue' or 'dequeue'"), nil)
                return
        }
-       if reqObj.CDN == nil && reqObj.CDNID == nil {
-               api.HandleErr(w, r, inf.Tx.Tx, http.StatusBadRequest, 
errors.New("cdn does not exist"), nil)
+       if reqObj.CDNID == nil && (reqObj.CDN == nil || *reqObj.CDN == "") {
+               api.HandleErr(w, r, inf.Tx.Tx, http.StatusBadRequest, 
errors.New("cdn is a required field"), nil)
                return
        }
-       if reqObj.CDN == nil || *reqObj.CDN == "" {
+       if reqObj.CDNID != nil && (reqObj.CDN == nil || *reqObj.CDN == "") {
                cdn, ok, err := dbhelpers.GetCDNNameFromID(inf.Tx.Tx, 
int64(*reqObj.CDNID))
                if err != nil {
                        api.HandleErr(w, r, inf.Tx.Tx, 
http.StatusInternalServerError, nil, errors.New("getting CDN name from ID 
'"+strconv.Itoa(int(*reqObj.CDNID))+"': "+err.Error()))

Reply via email to