You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ro...@apache.org on 2018/06/04 16:38:02 UTC
[incubator-trafficcontrol] 07/10: Fixed bug in GetReplaceHandler
using values before they were decoded
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/incubator-trafficcontrol.git
commit 54e8aff6ad6a6717760f8d84be46a55aac20829f
Author: ASchmidt <An...@comcast.com>
AuthorDate: Tue May 22 16:43:35 2018 -0600
Fixed bug in GetReplaceHandler using values before they were decoded
---
.../deliveryservice/servers/servers.go | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go b/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
index c6ba71a..a1d6ecf 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
@@ -308,8 +308,6 @@ func GetReplaceHandler(db *sqlx.DB) http.HandlerFunc {
// get list of server Ids to insert
payload := createServersForDsIdRef()
- servers := payload.Servers
- dsId := payload.DsId
if err := json.NewDecoder(r.Body).Decode(payload); err != nil {
log.Errorf("Error trying to decode the request body: %s", err)
@@ -317,6 +315,21 @@ func GetReplaceHandler(db *sqlx.DB) http.HandlerFunc {
return
}
+ servers := payload.Servers
+ dsId := payload.DsId
+
+ if servers == nil {
+ log.Error.Printf("no servers sent in POST; could not begin transaction: %v", err)
+ handleErrs(http.StatusBadRequest, err)
+ return
+ }
+
+ if dsId == nil {
+ log.Error.Printf("no delivery service id sent in POST; could not begin transaction: %v", err)
+ handleErrs(http.StatusBadRequest, err)
+ return
+ }
+
// if the object has tenancy enabled, check that user is able to access the tenant
// check user tenancy access to this resource.
row := db.QueryRow("SELECT xml_id FROM deliveryservice WHERE id = $1", *dsId)
--
To stop receiving notification emails like this one, please contact
rob@apache.org.