You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
improve error message of oras attach when subject artifact is not specified #1424
When using oras attach, if a user forgot to provide the subject artifact reference and only specifies one to-be-uploaded file, ORAS CLI will output (tested in bash, different shell might have different output):
> ARTIFACT=
> oras attach --artifact-type test/example $ARTIFACT./test.jsonError: neither file nor annotation provided in the commandUsage: oras attach [flags] --artifact-type=<type> <name>{:<tag>|@<digest>} <file>[:<layer_media_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 examplesdigest]
Input was parsed under a wrong consumption: user does specify subject artifact reference ./layers, which actually is a file reference to be attached. This error can be avoided by parsing the only input argument. If the reference is valid, continue with current output. If it's not, give corresponding hint like:
Error: "./test.json" is an invalid artifact referenceDid you forget to specify a subject artifact?
Sample error output (phrasing and wording still TBD)
> ./bin/linux/amd64/oras attach --artifact-type test/example "a-------"Error: "a-------": invalid reference: missing registry or repositoryHave you specified an artifact reference to attach to? Please make sure the provided reference is in the form of <registry>/<repo>[:tag|@digest][:tag|@digest]
Depends on different behavior of shell, if an empty env variable is interpolated into "" (zsh)
> ARTIFACT=
> ./bin/linux/amd64/oras attach --artifact-type test/example $ARTIFACT my.jsonError: "my.json": invalid reference: missing registry or repositoryHave you specified an artifact reference to attach to? Please make sure the provided reference is in the form of <registry>/<repo>[:tag|@digest]
> ./bin/linux/amd64/oras attach localhost:5000/test my.json --artifact-type test/exampleError: "localhost:5000/test": no tag or digest specifiedUsage: oras attach [flags] --artifact-type=<type> <name>{:<tag>|@<digest>} <file>[:<layer_media_type>] [...]Please specify a reference in the form of "<name>:<tag>" or "<name>@<digest>". Run "oras attach -h" for more options and examples
If an empty env variable is omitted (bash)
> ARTIFACT=
> ./bin/linux/amd64/oras attach --artifact-type test/example $ARTIFACT ./my.jsonError: "./my.json": no tag or digest specifiedUsage: oras attach [flags] --artifact-type=<type> <name>{:<tag>|@<digest>} <file>[:<layer_media_type>] [...]Have you specified an artifact reference to attach to? Please specify a reference in the form of "<name>:<tag>" or "<name>@<digest>". Run "oras attach -h" for more options and examples
@qweeah For this case, how about improving the error message as follows:
> oras attach --artifact-type test/example $ARTIFACT ./layers
Error: "./layers" is an invalid artifact reference.
Usage: oras attach [flags] --artifact-type=<type> <name>{:<tag>|@<digest>} <file>[:<layer_media_type>] | --annotation "key=val"
To attach files to an object, please specify a valid artifact reference and files via arguments in sequence". Run "oras attach -h" for more options and examples.
Activity
qweeah commentedon Jun 21, 2024
This should also resolve part of #1404
FeynmanZhou commentedon Jun 21, 2024
Can you pls also add the wrong
oras attachcommand in this issue?qweeah commentedon Jun 24, 2024
Sample error output (phrasing and wording still TBD)
Depends on different behavior of shell, if an empty env variable is interpolated into
""(zsh)If an empty env variable is omitted (bash)
FeynmanZhou commentedon Jun 27, 2024
@qweeah For this case, how about improving the error message as follows: