You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2022/02/11 22:51:31 UTC

[GitHub] [trafficcontrol] zrhoffman commented on a change in pull request #6552: Validate type in topology using current cache group name

zrhoffman commented on a change in pull request #6552:
URL: https://github.com/apache/trafficcontrol/pull/6552#discussion_r805055372



##########
File path: traffic_ops/traffic_ops_golang/cachegroup/cachegroups.go
##########
@@ -188,14 +188,30 @@ func (cg *TOCacheGroup) ValidateTypeInTopology() error {
 		return nil
 	}
 
+	// language=SQL
+	const previousNameQuery = `
+	SELECT name
+	FROM cachegroup c
+	WHERE c.id = $1
+	`
+	var previousName string
+	err = cg.ReqInfo.Tx.QueryRow(previousNameQuery, *cg.ID).Scan(&previousName)
+	if err == sql.ErrNoRows {
+		return nil
+	}
+	if err != nil {
+		log.Errorf("%s: getting the previous name of cachegroup %s: %s", userErr.Error(), *cg.Name, err.Error())

Review comment:
       This line panics  if `userErr` is nil. Changing `userErr.Error()` to `userErr` would fix that




-- 
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: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org