ocket8888 commented on code in PR #7848:
URL: https://github.com/apache/trafficcontrol/pull/7848#discussion_r1379106740


##########
traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go:
##########
@@ -388,7 +388,7 @@ func createV50(w http.ResponseWriter, r *http.Request, inf 
*api.APIInfo, ds tc.D
                return nil, http.StatusInternalServerError, nil, sysErr
        }
        if authorized, err := isTenantAuthorized(inf, &ds); err != nil {
-               return nil, http.StatusInternalServerError, nil, 
fmt.Errorf("checking tenant: %w", err)
+               return nil, http.StatusBadRequest, err, fmt.Errorf("checking 
tenant: %w", err)

Review Comment:
   This exposes error information from connections with the database to API 
clients. One of two things should instead be done:
   * check here that the error returned by `isTenantAuthorized` does/doesn't 
represent a failure to find any matching rows and handle appropriately (404 if 
yes, 500 otherwise)
   * refactor `isTenantAuthorized` to instead return a third value which 
indicates whether any such Tenant could be found a la 
[`dbhelpers.GetStatusByID`](https://pkg.go.dev/github.com/apache/[email protected]+incompatible/traffic_ops/traffic_ops_golang/dbhelpers#GetStatusByID)
 (and others). More work, but a better solution IMO.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to