17944: Improves error reporting on invalid value types.
authorLucas Di Pentima <lucas.dipentima@curii.com>
Wed, 10 Nov 2021 18:21:17 +0000 (15:21 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Wed, 10 Nov 2021 18:21:17 +0000 (15:21 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

sdk/go/arvados/vocabulary.go
sdk/go/arvados/vocabulary_test.go

index dc31b998f6fa4ff67ccdeda7910a865b072e43a7..8de6970781f8a60593b2ad0312857cc3ed685a4c 100644 (file)
@@ -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
index 050d5ea7625edf2e0b15ec121629113236f552ab..3099495a33da0bf2238cf95a2b96982b25e9a97a 100644 (file)
@@ -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)