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 2020/11/20 02:52:47 UTC

[GitHub] [trafficcontrol] MylesBock opened a new pull request #5314: 5285/improve validation error messages for divisions

MylesBock opened a new pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314


   <!--
   ************ STOP!! ************
   If this Pull Request is intended to fix a security vulnerability, DO NOT submit it! Instead, contact
   the Apache Software Foundation Security Team at security@trafficcontrol.apache.org and follow the
   guidelines at https://www.apache.org/security/ regarding vulnerability disclosure.
   -->
   ## What does this PR (Pull Request) do?
   
   Improves Validation and Validation error messages for Regions, now when a `POST` is fired at that endpoint without a division name it returns an appropriate error message.
   
   This may require additional documentation changes (swagger docs, maybe)
   
   <!-- Explain the changes you made here. If this fixes an Issue, identify it by
   replacing the text in the checkbox item with the Issue number e.g.
   
   - [x] This PR fixes #9001 OR is not related to any Issue
   
   ^ This will automatically close Issue number 9001 when the Pull Request is
   merged (The '#' is important).
   
   Be sure you check the box properly, see the "The following criteria are ALL
   met by this PR" section for details.
   -->
   
   - [x] This PR fixes #5285 <!-- You can check for an issue here: https://github.com/apache/trafficcontrol/issues -->
   
   
   ## Which Traffic Control components are affected by this PR?
   <!-- Please delete all components from this list that are NOT affected by this
   Pull Request. Also, feel free to add the name of a tool or script that is
   affected but not on the list.
   
   Additionally, if this Pull Request does NOT affect documentation, please
   explain why documentation is not required. -->
   
   - CDN in a Box
   - Documentation
   - Grove
   - Traffic Control Client <!-- Please specify which; e.g. 'Python', 'Go', 'Java' -->
   - Traffic Monitor
   - [x] Traffic Ops
   - Traffic Ops ORT
   - Traffic Portal
   - Traffic Router
   - Traffic Stats
   - Traffic Vault
   - CI tests
   
   ## What is the best way to verify this PR?
   <!-- Please include here ALL the steps necessary to test your Pull Request. If
   it includes tests (and most should), outline here the steps needed to run the
   tests. If not, lay out the manual testing procedure and please explain why
   tests are unnecessary for this Pull Request. -->
   Follow repro steps in #5285 description, ensure new error message is displayed
   
   ## If this is a bug fix, what versions of Traffic Control are affected?
   <!-- If this PR fixes a bug, please list here all of the affected versions - to
   the best of your knowledge. It's also pretty helpful to include a commit hash
   of where 'master' is at the time this PR is opened (if it affects master),
   because what 'master' means will change over time. For example, if this PR
   fixes a bug that's present in master (at commit hash '1df853c8'), in v4.0.0,
   and in the current 4.0.1 Release candidate (e.g. RC1), then this list would
   look like:
   
   - master (1df853c8)
   - 4.0.0
   - 4.0.1 (RC1)
   
   If you don't know what other versions might have this bug, AND don't know how
   to find the commit hash of 'master', then feel free to leave this section
   blank (or, preferably, delete it entirely).
    -->
   
   
   ## The following criteria are ALL met by this PR
   <!-- Check the boxes to signify that the associated statement is true. To
   "check a box", replace the space inside of the square brackets with an 'x'.
   e.g.
   
   - [ x] <- Wrong
   - [x ] <- Wrong
   - [] <- Wrong
   - [*] <- Wrong
   - [x] <- Correct!
   
   -->
   
   - [x] This PR includes tests OR I have explained why tests are unnecessary
   - [x] This PR includes documentation OR I have explained why documentation is unnecessary
   - [x] This PR includes an update to CHANGELOG.md OR such an update is not necessary
   - [x] This PR includes any and all required license headers
   - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://www.apache.org/security/) for details)
   
   
   ## Additional Information
   <!-- If you would like to include any additional information on the PR for
   potential reviewers please put it here.
   
   Some examples of this would be:
   
   - Before and after screenshots/gifs of the Traffic Portal if it is affected
   - Links to other dependent Pull Requests
   - References to relevant context (e.g. new/updates to dependent libraries,
   mailing list records, blueprints)
   
   Feel free to leave this section blank (or, preferably, delete it entirely).
   -->
   
   <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
   -->
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314#discussion_r529866915



##########
File path: traffic_ops/traffic_ops_golang/region/regions_test.go
##########
@@ -109,3 +108,30 @@ func TestInterfaces(t *testing.T) {
 		t.Errorf("Region must be Identifier")
 	}
 }
+func TestValidation(t *testing.T) {
+	testRegion := tc.Region{
+		DivisionName: "west",
+		ID:           1,
+		Name:         "region1",
+		LastUpdated:  tc.TimeNoMod{Time: time.Now()},
+	}
+	testTORegion := TORegion{Region: testRegion}
+	errs := test.SortErrors(test.SplitErrors(testTORegion.Validate()))
+
+	if len(errs) > 0 {
+		t.Errorf(`expected no errors,  got %v`, errs)

Review comment:
       No, I don't think so. I think only the ID should be required, as the docs say:
   
   > _"The only “division” key that actually matters in the request body is `division`; `divisionName` is not validated and has no effect - particularly not the effect of re-naming the division - beyond changing the name in the API response to this request. Subsequent requests will reveal the true name of the division. Note that if `divisionName` is not present in the request body it will be null in the response, but again further requests will show the true division name (provided it has been assigned to a division)._"




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] MylesBock commented on a change in pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
MylesBock commented on a change in pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314#discussion_r527981855



##########
File path: traffic_ops/traffic_ops_golang/region/regions_test.go
##########
@@ -20,14 +20,13 @@ package region
  */
 
 import (
-	"testing"
-	"time"
-
 	"github.com/apache/trafficcontrol/lib/go-tc"
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/test"
 	"github.com/jmoiron/sqlx"
 	sqlmock "gopkg.in/DATA-DOG/go-sqlmock.v1"
+	"testing"
+	"time"

Review comment:
       Done, thanks




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314#discussion_r529866915



##########
File path: traffic_ops/traffic_ops_golang/region/regions_test.go
##########
@@ -109,3 +108,30 @@ func TestInterfaces(t *testing.T) {
 		t.Errorf("Region must be Identifier")
 	}
 }
+func TestValidation(t *testing.T) {
+	testRegion := tc.Region{
+		DivisionName: "west",
+		ID:           1,
+		Name:         "region1",
+		LastUpdated:  tc.TimeNoMod{Time: time.Now()},
+	}
+	testTORegion := TORegion{Region: testRegion}
+	errs := test.SortErrors(test.SplitErrors(testTORegion.Validate()))
+
+	if len(errs) > 0 {
+		t.Errorf(`expected no errors,  got %v`, errs)

Review comment:
       No, I don't think so. I think only the ID should be required, as the docs say:
   
   > _"The only “division” key that actually matters in the request body is `division`; `divisionName` is not validated and has no effect - particularly not the effect of re-naming the division - beyond changing the name in the API response to this request. Subsequent requests will reveal the true name of the division. Note that if `divisionName` is not present in the request body it will be null in the response, but again further requests will show the true division name (provided it has been assigned to a division)._"
   
   It's not important to maintain the behavior of giving back the user a potentially incorrect `divisionName`, but the docs do explicitly state that the ID is the one - and the only one - of the two that is required.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] MylesBock commented on a change in pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
MylesBock commented on a change in pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314#discussion_r527983684



##########
File path: traffic_ops/traffic_ops_golang/region/regions_test.go
##########
@@ -20,14 +20,13 @@ package region
  */
 
 import (
-	"testing"
-	"time"
-
 	"github.com/apache/trafficcontrol/lib/go-tc"
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/test"
 	"github.com/jmoiron/sqlx"
 	sqlmock "gopkg.in/DATA-DOG/go-sqlmock.v1"
+	"testing"
+	"time"

Review comment:
       Nevermind definitely not resolved, gofmt wont let me follow that convention as-is, goland also formats it the way I pushed it




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] MylesBock commented on pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
MylesBock commented on pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314#issuecomment-733106944


   @ocket8888 merged your PR


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] MylesBock commented on a change in pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
MylesBock commented on a change in pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314#discussion_r530017340



##########
File path: traffic_ops/traffic_ops_golang/region/regions_test.go
##########
@@ -109,3 +108,30 @@ func TestInterfaces(t *testing.T) {
 		t.Errorf("Region must be Identifier")
 	}
 }
+func TestValidation(t *testing.T) {
+	testRegion := tc.Region{
+		DivisionName: "west",
+		ID:           1,
+		Name:         "region1",
+		LastUpdated:  tc.TimeNoMod{Time: time.Now()},
+	}
+	testTORegion := TORegion{Region: testRegion}
+	errs := test.SortErrors(test.SplitErrors(testTORegion.Validate()))
+
+	if len(errs) > 0 {
+		t.Errorf(`expected no errors,  got %v`, errs)

Review comment:
       Removed divisionName from the validation, updated test slightly




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] MylesBock commented on a change in pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
MylesBock commented on a change in pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314#discussion_r529060606



##########
File path: traffic_ops/traffic_ops_golang/region/regions_test.go
##########
@@ -20,14 +20,13 @@ package region
  */
 
 import (
-	"testing"
-	"time"
-
 	"github.com/apache/trafficcontrol/lib/go-tc"
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/test"
 	"github.com/jmoiron/sqlx"
 	sqlmock "gopkg.in/DATA-DOG/go-sqlmock.v1"
+	"testing"
+	"time"

Review comment:
       I went with what gofmt did to it locally, is this okay to squash and proceed?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] MylesBock commented on a change in pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
MylesBock commented on a change in pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314#discussion_r527846232



##########
File path: traffic_ops/traffic_ops_golang/region/regions_test.go
##########
@@ -109,3 +108,30 @@ func TestInterfaces(t *testing.T) {
 		t.Errorf("Region must be Identifier")
 	}
 }
+func TestValidation(t *testing.T) {
+	testRegion := tc.Region{
+		DivisionName: "west",
+		ID:           1,
+		Name:         "region1",
+		LastUpdated:  tc.TimeNoMod{Time: time.Now()},
+	}
+	testTORegion := TORegion{Region: testRegion}
+	errs := test.SortErrors(test.SplitErrors(testTORegion.Validate()))
+
+	if len(errs) > 0 {
+		t.Errorf(`expected no errors,  got %v`, errs)

Review comment:
       Yes, had changes to do that but pivoted because it was pretty late
   
   Test fixture updated to include a division, error message updated




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314#discussion_r530543704



##########
File path: traffic_ops/traffic_ops_golang/region/regions.go
##########
@@ -95,7 +95,10 @@ func (region *TORegion) GetType() string {
 
 func (region *TORegion) Validate() error {
 	if len(region.Name) < 1 {
-		return errors.New(`Region 'name' is required.`)
+		return errors.New(`region 'name' is required`)
+	}
+	if region.Division == 0 {
+		return errors.New(`region 'division' is are required`)

Review comment:
       nit:
   
   ```diff
   -		return errors.New(`region 'division' is are required`)
   +		return errors.New(`region 'division' is required`)
   ```




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314#discussion_r527841035



##########
File path: traffic_ops/traffic_ops_golang/region/regions_test.go
##########
@@ -109,3 +108,30 @@ func TestInterfaces(t *testing.T) {
 		t.Errorf("Region must be Identifier")
 	}
 }
+func TestValidation(t *testing.T) {
+	testRegion := tc.Region{
+		DivisionName: "west",
+		ID:           1,
+		Name:         "region1",
+		LastUpdated:  tc.TimeNoMod{Time: time.Now()},
+	}
+	testTORegion := TORegion{Region: testRegion}
+	errs := test.SortErrors(test.SplitErrors(testTORegion.Validate()))
+
+	if len(errs) > 0 {
+		t.Errorf(`expected no errors,  got %v`, errs)

Review comment:
       This expects no errors because you provided `DivisionName`, but the validation requires `Division` *and* `DivisionName` as it's currently written. Which is why the test fails.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314#discussion_r527960092



##########
File path: traffic_ops/traffic_ops_golang/region/regions_test.go
##########
@@ -20,14 +20,13 @@ package region
  */
 
 import (
-	"testing"
-	"time"
-
 	"github.com/apache/trafficcontrol/lib/go-tc"
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/test"
 	"github.com/jmoiron/sqlx"
 	sqlmock "gopkg.in/DATA-DOG/go-sqlmock.v1"
+	"testing"
+	"time"

Review comment:
       Import grouping should be:
   
   1. Standard library
   1. `golang.org/x/*`
   1. External/vendored libraries (e.g. `sqlx`)
   1. Project-local packages




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] MylesBock commented on a change in pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
MylesBock commented on a change in pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314#discussion_r527550407



##########
File path: traffic_ops/traffic_ops_golang/region/regions_test.go
##########
@@ -109,3 +109,30 @@ func TestInterfaces(t *testing.T) {
 		t.Errorf("Region must be Identifier")
 	}
 }
+func TestValidation(t *testing.T) {
+	testRegion := tc.Region{
+		DivisionName: "west",
+		ID:           1,
+		Name:         "region1",
+		LastUpdated:  tc.TimeNoMod{Time: time.Now()},
+	}
+	testTORegion := TORegion{Region: testRegion}
+	errs := test.SortErrors(test.SplitErrors(testTORegion.Validate()))
+	expected := []error{}
+
+	if reflect.DeepEqual(expected, errs) {

Review comment:
       copypasted test, will update it as it seemed weird where i grabbed it from (`divisions_test.go`)




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] MylesBock commented on a change in pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
MylesBock commented on a change in pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314#discussion_r529785701



##########
File path: traffic_ops/traffic_ops_golang/region/regions_test.go
##########
@@ -109,3 +108,30 @@ func TestInterfaces(t *testing.T) {
 		t.Errorf("Region must be Identifier")
 	}
 }
+func TestValidation(t *testing.T) {
+	testRegion := tc.Region{
+		DivisionName: "west",
+		ID:           1,
+		Name:         "region1",
+		LastUpdated:  tc.TimeNoMod{Time: time.Now()},
+	}
+	testTORegion := TORegion{Region: testRegion}
+	errs := test.SortErrors(test.SplitErrors(testTORegion.Validate()))
+
+	if len(errs) > 0 {
+		t.Errorf(`expected no errors,  got %v`, errs)

Review comment:
       What is the intended functionality here for this validation? Should both Division and DivisionName be required?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314#discussion_r527505251



##########
File path: traffic_ops/traffic_ops_golang/region/regions_test.go
##########
@@ -109,3 +109,30 @@ func TestInterfaces(t *testing.T) {
 		t.Errorf("Region must be Identifier")
 	}
 }
+func TestValidation(t *testing.T) {
+	testRegion := tc.Region{
+		DivisionName: "west",
+		ID:           1,
+		Name:         "region1",
+		LastUpdated:  tc.TimeNoMod{Time: time.Now()},
+	}
+	testTORegion := TORegion{Region: testRegion}
+	errs := test.SortErrors(test.SplitErrors(testTORegion.Validate()))
+	expected := []error{}
+
+	if reflect.DeepEqual(expected, errs) {

Review comment:
       You should avoid using `reflect.DeepEqual` to compare error values in tests - and actually I think `golang-lint` warns about this by default. The reason is that errors are consistently appended to outer errors to build an idea of the scope of the error and at what level it occurred. Because of that or just adding more context, error strings change all the time, so using `reflect.DeepEqual` makes tests brittle.
   
   Plus in this particular case, you're only looking for an empty set of errors, so you can easily check `len(errs) != 0` instead.

##########
File path: traffic_ops/traffic_ops_golang/region/regions.go
##########
@@ -95,7 +95,11 @@ func (region *TORegion) GetType() string {
 
 func (region *TORegion) Validate() error {
 	if len(region.Name) < 1 {
-		return errors.New(`Region 'name' is required.`)
+		return errors.New(`region 'name' is required`)
+	}
+	if region.DivisionName == "" || region.Division == 0 {
+		// golang style guides say error strings shouldn't be capitalized or end with punctuation

Review comment:
       NIT: This is true, but you don't need to mention it. Otherwise it could go above every instantiation of an error, and that's how we wound up with
   
   ```go
   //this utilizes the non panicking type assertion, if the thrown away ok variable is false i will be the zero of the type, 0 here.
   ```
   pasted a million times all over the codebase.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 merged pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
ocket8888 merged pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] MylesBock commented on a change in pull request #5314: Improve validation error message for regions with no division name

Posted by GitBox <gi...@apache.org>.
MylesBock commented on a change in pull request #5314:
URL: https://github.com/apache/trafficcontrol/pull/5314#discussion_r527550960



##########
File path: traffic_ops/traffic_ops_golang/region/regions.go
##########
@@ -95,7 +95,11 @@ func (region *TORegion) GetType() string {
 
 func (region *TORegion) Validate() error {
 	if len(region.Name) < 1 {
-		return errors.New(`Region 'name' is required.`)
+		return errors.New(`region 'name' is required`)
+	}
+	if region.DivisionName == "" || region.Division == 0 {
+		// golang style guides say error strings shouldn't be capitalized or end with punctuation

Review comment:
       fair enough, was just providing my rationale for changing the existing error message




----------------------------------------------------------------
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:
users@infra.apache.org