From 5c39ec65261cbe111313ff5589bf511cad3758e9 Mon Sep 17 00:00:00 2001 From: Rebecca Mahany-Horton Date: Wed, 23 Oct 2024 14:25:23 -0400 Subject: [PATCH] If we don't have any TUF metadata locally, return friendlier error message (#1907) --- ee/tuf/library_lookup.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ee/tuf/library_lookup.go b/ee/tuf/library_lookup.go index db0892a68..f59c2ba45 100644 --- a/ee/tuf/library_lookup.go +++ b/ee/tuf/library_lookup.go @@ -2,6 +2,7 @@ package tuf import ( "context" + "errors" "fmt" "log/slog" "os" @@ -248,7 +249,10 @@ func findExecutable(ctx context.Context, binary autoupdatableBinary, tufReposito // From already-downloaded metadata, look for the release version targets, err := metadataClient.Targets() if err != nil { - return nil, fmt.Errorf("could not get target: %w", err) + return nil, fmt.Errorf("could not get targets: %w", err) + } + if len(targets) == 0 { + return nil, errors.New("no local TUF metadata available -- likely new install") } targetName, _, err := findTarget(ctx, binary, targets, pinnedVersion, channel, slogger)