ocket8888 commented on a change in pull request #5071:
URL: https://github.com/apache/trafficcontrol/pull/5071#discussion_r502720258



##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/request/validate.go
##########
@@ -20,22 +20,27 @@ package request
  */
 
 import (
+       "database/sql"
        "errors"
        "fmt"
-       "strconv"
 
+       "github.com/apache/trafficcontrol/lib/go-log"
        "github.com/apache/trafficcontrol/lib/go-tc"
        "github.com/apache/trafficcontrol/lib/go-tc/tovalidate"
        "github.com/apache/trafficcontrol/lib/go-util"
 
-       "github.com/go-ozzo/ozzo-validation"
+       validation "github.com/go-ozzo/ozzo-validation"
 )
 
 // Validate ensures all required fields are present and in correct form.  Also 
checks request JSON is complete and valid
-func (req *TODeliveryServiceRequest) Validate() error {
+func validateLegacy(dsr tc.DeliveryServiceRequestV15, tx *sql.Tx) error {
+       if tx == nil {
+               log.Errorln("validating a legacy Delivery Service Request: nil 
transaction was passed")
+       }
+
        fromStatus := tc.RequestStatusDraft
-       if req.ID != nil && *req.ID > 0 {
-               err := req.APIInfo().Tx.Tx.QueryRow(`SELECT status FROM 
deliveryservice_request WHERE id=` + strconv.Itoa(*req.ID)).Scan(&fromStatus)
+       if dsr.ID != nil && *dsr.ID > 0 {
+               err := tx.QueryRow(`SELECT status FROM deliveryservice_request 
WHERE id=$1`, *dsr.ID).Scan(&fromStatus)
 
                if err != nil {
                        return err

Review comment:
       The only option, then, would be to swallow it. Validation pipelines do 
not allow system vs user-facing errors. FWIW, that behavior existed before I 
touched this code.




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


Reply via email to