diff --git a/core/pkg/sync/blob/blob_sync.go b/core/pkg/sync/blob/blob_sync.go index df41a753a..c752dff98 100644 --- a/core/pkg/sync/blob/blob_sync.go +++ b/core/pkg/sync/blob/blob_sync.go @@ -18,10 +18,10 @@ import ( ) type Sync struct { - Bucket string - Object string + Bucket string + Object string // FileType indicates the file type e.g., json, yaml/yml etc., - fileType string + fileType string BlobURLMux *blob.URLMux Cron Cron Logger *logger.Logger @@ -142,7 +142,11 @@ func (hs *Sync) fetchObject(ctx context.Context, bucket *blob.Bucket) (string, e switch hs.fileType { case "yaml", "yml": - return utils.YAMLToJSON(buf.Bytes()) + str, err := utils.YAMLToJSON(buf.Bytes()) + if err != nil { + return "", fmt.Errorf("error converting blob from yaml to json: %w", err) + } + return str, nil case "json": return buf.String(), nil default: @@ -151,4 +155,3 @@ func (hs *Sync) fetchObject(ctx context.Context, bucket *blob.Bucket) (string, e // return "", fmt.Errorf("filepath extension for URI: '%s' is not supported", hs.sync()) } } - diff --git a/core/pkg/sync/file/filepath_sync.go b/core/pkg/sync/file/filepath_sync.go index 8f2739df6..4a3a13918 100644 --- a/core/pkg/sync/file/filepath_sync.go +++ b/core/pkg/sync/file/filepath_sync.go @@ -186,7 +186,11 @@ func (fs *Sync) fetch(_ context.Context) (string, error) { switch fs.fileType { case "yaml", "yml": - return utils.YAMLToJSON(rawFile) + str, err := utils.YAMLToJSON(rawFile) + if err != nil { + return "", fmt.Errorf("error converting file from yaml to json: %w", err) + } + return str, nil case "json": return string(rawFile), nil default: