[ARVADOS] updated: 2.1.0-1592-g617d78398

Git user git at public.arvados.org
Wed Nov 10 19:39:22 UTC 2021


Summary of changes:
 sdk/go/arvados/vocabulary.go      | 11 +++++-----
 sdk/go/arvados/vocabulary_test.go | 43 +++++++++++++++++++++++++++++++++++++--
 2 files changed, 47 insertions(+), 7 deletions(-)

       via  617d783980943ac7cda84d94a5a43e06adeb838e (commit)
       via  613b22c08b3fb2fb24a15b17ce7de04e3f7ebc35 (commit)
      from  c51e85a536ec9520ce9c8784bf26b639f7e4ce0a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 617d783980943ac7cda84d94a5a43e06adeb838e
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date:   Wed Nov 10 16:31:12 2021 -0300

    17944: Only check for value aliases collision between different values.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>

diff --git a/sdk/go/arvados/vocabulary.go b/sdk/go/arvados/vocabulary.go
index 8de697078..150091b30 100644
--- a/sdk/go/arvados/vocabulary.go
+++ b/sdk/go/arvados/vocabulary.go
@@ -112,13 +112,14 @@ func (v *Vocabulary) validate() error {
 			if tagValues[lcVal] != "" {
 				return fmt.Errorf("duplicate tag value %q for tag %q", val, key)
 			}
+			// Checks for collisions between labels from different values.
 			tagValues[lcVal] = val
 			for _, tagLbl := range v.Tags[key].Values[val].Labels {
 				label := strings.ToLower(tagLbl.Label)
-				if tagValues[label] != "" {
-					return fmt.Errorf("tag value label %q for pair (%q:%q) already seen as a value key or label", tagLbl.Label, key, val)
+				if tagValues[label] != "" && tagValues[label] != val {
+					return fmt.Errorf("tag value label %q for pair (%q:%q) already seen on value %q", tagLbl.Label, key, val, tagValues[label])
 				}
-				tagValues[label] = tagLbl.Label
+				tagValues[label] = val
 			}
 		}
 	}
diff --git a/sdk/go/arvados/vocabulary_test.go b/sdk/go/arvados/vocabulary_test.go
index 3099495a3..5a5189de2 100644
--- a/sdk/go/arvados/vocabulary_test.go
+++ b/sdk/go/arvados/vocabulary_test.go
@@ -220,7 +220,8 @@ func (s *VocabularySuite) TestNewVocabulary(c *check.C) {
 					"labels": [{"label": "Animal"}, {"label": "Creature"}],
 					"values": {
 						"IDVALANIMAL1":{"labels":[{"label":"Human"}, {"label":"Homo sapiens"}]},
-						"IDVALANIMAL2":{"labels":[{"label":"Elephant"}, {"label":"Loxodonta"}]}
+						"IDVALANIMAL2":{"labels":[{"label":"Elephant"}, {"label":"Loxodonta"}]},
+						"DOG":{"labels":[{"label":"Dog"}, {"label":"Canis lupus familiaris"}, {"label":"dOg"}]}
 					}
 				}
 			}}`,
@@ -248,6 +249,9 @@ func (s *VocabularySuite) TestNewVocabulary(c *check.C) {
 							"IDVALANIMAL2": {
 								Labels: []VocabularyLabel{{Label: "Elephant"}, {Label: "Loxodonta"}},
 							},
+							"DOG": {
+								Labels: []VocabularyLabel{{Label: "Dog"}, {Label: "Canis lupus familiaris"}, {Label: "dOg"}},
+							},
 						},
 					},
 				},
@@ -405,7 +409,28 @@ func (s *VocabularySuite) TestValidationErrors(c *check.C) {
 					},
 				},
 			},
-			"tag value label.*for pair.*already seen.*",
+			"tag value label.*for pair.*already seen.*on value.*",
+		},
+		{
+			"Collision between tag value labels (case-insensitive)",
+			&Vocabulary{
+				StrictTags: false,
+				Tags: map[string]VocabularyTag{
+					"IDTAGANIMALS": {
+						Strict: false,
+						Labels: []VocabularyLabel{{Label: "Animal"}, {Label: "Creature"}},
+						Values: map[string]VocabularyTagValue{
+							"IDVALANIMAL1": {
+								Labels: []VocabularyLabel{{Label: "Human"}, {Label: "Mammal"}},
+							},
+							"IDVALANIMAL2": {
+								Labels: []VocabularyLabel{{Label: "Elephant"}, {Label: "mAMMAL"}},
+							},
+						},
+					},
+				},
+			},
+			"tag value label.*for pair.*already seen.*on value.*",
 		},
 		{
 			"Strict tag key, with no values",

commit 613b22c08b3fb2fb24a15b17ce7de04e3f7ebc35
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date:   Wed Nov 10 15:21:17 2021 -0300

    17944: Improves error reporting on invalid value types.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>

diff --git a/sdk/go/arvados/vocabulary.go b/sdk/go/arvados/vocabulary.go
index dc31b998f..8de697078 100644
--- a/sdk/go/arvados/vocabulary.go
+++ b/sdk/go/arvados/vocabulary.go
@@ -208,11 +208,11 @@ func (v *Vocabulary) Check(data map[string]interface{}) error {
 						return err
 					}
 				default:
-					return fmt.Errorf("tag value of type %T for key %q is not a valid", singleVal, key)
+					return fmt.Errorf("value list element type for tag key %q was %T, but expected a string", key, singleVal)
 				}
 			}
 		default:
-			return fmt.Errorf("tag value of type %T for key %q is not a valid", val, key)
+			return fmt.Errorf("value type for tag key %q was %T, but expected a string or list of strings", key, val)
 		}
 	}
 	return nil
diff --git a/sdk/go/arvados/vocabulary_test.go b/sdk/go/arvados/vocabulary_test.go
index 050d5ea76..3099495a3 100644
--- a/sdk/go/arvados/vocabulary_test.go
+++ b/sdk/go/arvados/vocabulary_test.go
@@ -168,6 +168,20 @@ func (s *VocabularySuite) TestCheck(c *check.C) {
 			false,
 			"tag value.*is not valid for key.*",
 		},
+		{
+			"Invalid value type",
+			false,
+			`{"IDTAGANIMALS":1}`,
+			false,
+			"value type for tag key.* was.*, but expected a string or list of strings",
+		},
+		{
+			"Value list of invalid type",
+			false,
+			`{"IDTAGANIMALS":[1]}`,
+			false,
+			"value list element type for tag key.* was.*, but expected a string",
+		},
 	}
 	for _, tt := range tests {
 		c.Log(c.TestName()+" ", tt.name)

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list