17944: Makes returning an empty Vocabulary also include an empty "tags".
authorLucas Di Pentima <lucas.dipentima@curii.com>
Tue, 2 Nov 2021 20:03:49 +0000 (17:03 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Tue, 2 Nov 2021 22:34:27 +0000 (19:34 -0300)
...instead of returning "tags":null which makes workbench2's code to fail.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

lib/controller/localdb/conn.go

index edbbcb09cd30a13b8676f940c947d3e38713da08..9d1aa53621447b2f196be82c369c537ef0e2da23 100644 (file)
@@ -126,7 +126,9 @@ func (conn *Conn) loadVocabularyFile() error {
 // VocabularyGet refreshes the vocabulary cache if necessary and returns it.
 func (conn *Conn) VocabularyGet(ctx context.Context) (arvados.Vocabulary, error) {
        if conn.cluster.API.VocabularyPath == "" {
-               return arvados.Vocabulary{}, nil
+               return arvados.Vocabulary{
+                       Tags: map[string]arvados.VocabularyTag{},
+               }, nil
        }
        logger := ctxlog.FromContext(ctx)
        if conn.vocabularyCache == nil {
@@ -134,7 +136,9 @@ func (conn *Conn) VocabularyGet(ctx context.Context) (arvados.Vocabulary, error)
                err := conn.loadVocabularyFile()
                if err != nil {
                        logger.WithError(err).Error("error loading vocabulary file")
-                       return arvados.Vocabulary{}, err
+                       return arvados.Vocabulary{
+                               Tags: map[string]arvados.VocabularyTag{},
+                       }, err
                }
                go watchVocabulary(logger, conn.cluster.API.VocabularyPath, func() {
                        logger.Info("vocabulary file changed, it'll be reloaded next time it's needed")