From 175ffae56f3756b70753ec60daeef5639cbb87a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Thu, 10 Oct 2024 22:02:24 +0200 Subject: [PATCH] Improve an error message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We are seeing > reference "[overlay@...]quay.io/...@sha256:..." does not resolve to an image ID: identifier is not an image which is misleading; hide the ErrNoSuchImage text. Signed-off-by: Miloslav Trmač --- storage/storage_reference.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/storage/storage_reference.go b/storage/storage_reference.go index acc4cb30e8..5775c4acbc 100644 --- a/storage/storage_reference.go +++ b/storage/storage_reference.go @@ -153,7 +153,9 @@ func (s *storageReference) resolveImage(sys *types.SystemContext) (*storage.Imag } if s.id == "" { logrus.Debugf("reference %q does not resolve to an image ID", s.StringWithinTransport()) - return nil, fmt.Errorf("reference %q does not resolve to an image ID: %w", s.StringWithinTransport(), ErrNoSuchImage) + // %.0w makes the error visible to error.Unwrap() without including any text. + // ErrNoSuchImage ultimately is “identifier is not an image”, which is not helpful for identifying the root cause. + return nil, fmt.Errorf("reference %q does not resolve to an image ID%.0w", s.StringWithinTransport(), ErrNoSuchImage) } if loadedImage == nil { img, err := s.transport.store.Image(s.id)