From 0b6651ab310cd4e03a016537d214f7a1ff59f4f3 Mon Sep 17 00:00:00 2001 From: Shubham Singh <116020663+1Shubham7@users.noreply.github.com> Date: Thu, 27 Jul 2023 09:05:11 +0530 Subject: [PATCH] chore: improving error log for `oras push` and `oras attach` when the annotation file is invalid (#1026) Signed-off-by: Shubham Singh --- cmd/oras/internal/option/packer.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/oras/internal/option/packer.go b/cmd/oras/internal/option/packer.go index d32fa62de..ad633dd65 100644 --- a/cmd/oras/internal/option/packer.go +++ b/cmd/oras/internal/option/packer.go @@ -99,7 +99,13 @@ func (opts *Packer) LoadManifestAnnotations() (annotations map[string]map[string } if opts.AnnotationFilePath != "" { if err = decodeJSON(opts.AnnotationFilePath, &annotations); err != nil { - return nil, err + errStr := err.Error() + docLink := " Please refer to the document at https://oras.land/docs/how_to_guides/manifest_annotations." + if !strings.HasSuffix(errStr, ".") { + docLink = "."+docLink + } + return nil, fmt.Errorf("failed to load annotations from %s: %w" + + docLink, opts.AnnotationFilePath, err) } } if len(opts.ManifestAnnotations) != 0 {