Skip to content

improve error message when attaching with invalid input #1214

@qweeah

Description

@qweeah

if no file or annotation is provided

$ oras attach --artifact-type sbom/example localhost:5000/sample/images:foobar
Error: no blob is provided

Suggested error message:

$ oras attach --artifact-type sbom/example localhost:5000/sample/images:foobar
Error: neither file nor annotation provided in the command
Usage: oras attach [flags] --artifact-type=<type> <name>{:<tag>|@<digest>} <file>[:<type>] [...]
To attach to an existing artifact, please provide files via argument or annotations via flag "--annotation". Run "oras attach -h" for more options and examples

If the provided annotation file is invalid

Current behavior and output:

$ oras push --annotation-file sbom.json ghcr.io/library/alpine:3.9
Error: failed to load annotations from sbom.json: json: cannot unmarshal string into Go value of type map[string]map[string]string. Please refer to the document at https://oras.land/docs/how_to_guides/manifest_annotations

Suggested error message:

$ oras push --annotation-file annotation.json ghcr.io/library/alpine:3.9
Error: invalid annotation json file: failed to load annotations from annotation.json.
Annotation file doesn't match the required format. Please refer to the document at https://oras.land/docs/how_to_guides/manifest_annotations

Metadata

Metadata

Labels

uxUser experience related

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions