From d13fc649fc40aa813114d0b331b66b5e8850ad24 Mon Sep 17 00:00:00 2001 From: reubenmiller Date: Wed, 22 Jan 2025 10:25:05 +0100 Subject: [PATCH] fix: propagate fetcher errors back to the user --- pkg/c8yfetcher/c8yfetcher.go | 8 ++++++-- pkg/mapbuilder/mapbuilder.go | 6 ++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/c8yfetcher/c8yfetcher.go b/pkg/c8yfetcher/c8yfetcher.go index c7968c397..0fc8140d8 100644 --- a/pkg/c8yfetcher/c8yfetcher.go +++ b/pkg/c8yfetcher/c8yfetcher.go @@ -130,8 +130,10 @@ func lookupEntity(fetch EntityFetcher, values []string, getID bool, format strin Data: resultSet, }) } + } else { + // Propagate errors back to the caller + return entities, err } - // TODO: Handle error } else { entities = append(entities, entityReference{ ID: applyFormatter(id, format), @@ -150,8 +152,10 @@ func lookupEntity(fetch EntityFetcher, values []string, getID bool, format strin Data: resultSet, }) } + } else { + // Propagate errors back to the caller + return entities, err } - // TODO: Handle error } return entities, nil diff --git a/pkg/mapbuilder/mapbuilder.go b/pkg/mapbuilder/mapbuilder.go index 3b238bdf2..675fe86b1 100644 --- a/pkg/mapbuilder/mapbuilder.go +++ b/pkg/mapbuilder/mapbuilder.go @@ -1060,10 +1060,8 @@ func (b *MapBuilder) MarshalJSONObject() (body []byte, err error) { Logger.Debugf("body iterator. path=%s, value=%s", it.Path, value) if itErr != nil { - if itErr == io.EOF { - err = itErr - return - } + err = itErr + return } else { switch extInput := input.(type) { case []byte: