Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc (spec): add error message guideline #1163

Merged
merged 52 commits into from
Feb 23, 2024
Merged
Changes from 5 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
aa34c23
doc: add ORAS CLI proposal doc
FeynmanZhou Jan 10, 2023
5e05838
doc: add ORAS CLI proposal doc
FeynmanZhou Jan 10, 2023
cce1f66
doc: update the compatibility mode proposal
FeynmanZhou Jan 10, 2023
0066516
update compatibility doc
FeynmanZhou Jan 28, 2023
4013c48
Merge branch 'main' into main
FeynmanZhou Jan 28, 2023
49a20b0
update compatibility doc to resolve Billy's comments
FeynmanZhou Jan 29, 2023
cb5e7bc
Merge branch 'main' of https://github.com/FeynmanZhou/oras
FeynmanZhou Jan 29, 2023
9addaa3
update the compatibility doc to resolve Shiwei's comments
FeynmanZhou Jan 30, 2023
e4d1922
update the compatibility doc to resolve Shiwei's comments
FeynmanZhou Jan 30, 2023
506ec41
Merge branch 'main' into main
FeynmanZhou Jan 30, 2023
0c5d128
Merge branch 'main' of https://github.com/FeynmanZhou/oras; branch 'm…
FeynmanZhou Mar 6, 2023
c5bc0bf
fix broken logo link
FeynmanZhou Apr 27, 2023
eb2a1ae
Merge branch 'main' of https://github.com/oras-project/oras
FeynmanZhou Aug 21, 2023
e65a543
Merge branch 'main' of https://github.com/oras-project/oras
FeynmanZhou Nov 2, 2023
0ec0703
add error handling guide
FeynmanZhou Nov 2, 2023
4b63f4a
update error message examples
FeynmanZhou Nov 10, 2023
76db991
update error message examples
FeynmanZhou Nov 10, 2023
20b2084
Merge branch 'main' of https://github.com/oras-project/oras into erro…
FeynmanZhou Nov 10, 2023
39ff6ae
update error message examples
FeynmanZhou Nov 10, 2023
95ec9cb
resolve comments
FeynmanZhou Nov 15, 2023
16e86cf
resolve comments
FeynmanZhou Nov 15, 2023
764b9bb
resolve comments and update examples
FeynmanZhou Nov 17, 2023
68c8907
update cli error guideline
FeynmanZhou Nov 29, 2023
c74a6d3
refine CLI error guideline
FeynmanZhou Nov 29, 2023
3510594
refine examples
FeynmanZhou Dec 5, 2023
1792ab0
update cli guideline
FeynmanZhou Dec 11, 2023
b4f8c26
resolve comments
FeynmanZhou Dec 11, 2023
7adf1aa
update CLI error guideline
FeynmanZhou Dec 13, 2023
5ac34af
resolve comments
FeynmanZhou Dec 18, 2023
6669a4e
resolve comments
FeynmanZhou Dec 18, 2023
5287047
add more examples
FeynmanZhou Dec 20, 2023
5e31ce2
resolve comments and add more examples
FeynmanZhou Dec 22, 2023
d960843
Merge branch 'main' of https://github.com/oras-project/oras into erro…
FeynmanZhou Dec 22, 2023
7dccd63
resolve comments and add more examples
FeynmanZhou Dec 22, 2023
9d25f26
Merge branch 'main' into error-guide
qweeah Dec 25, 2023
1526f87
resolve comments and refine error guideline
FeynmanZhou Dec 25, 2023
4b36290
Merge branch 'main' of https://github.com/oras-project/oras into erro…
FeynmanZhou Dec 25, 2023
2c95904
Merge branch 'error-guide' of https://github.com/FeynmanZhou/oras int…
FeynmanZhou Dec 25, 2023
60f889e
resolve comments
FeynmanZhou Dec 25, 2023
7915e64
resolve comments
FeynmanZhou Dec 26, 2023
193ac35
resolve comments and refine spec
FeynmanZhou Jan 2, 2024
15eb3cc
add two examples and one suggestion
FeynmanZhou Jan 2, 2024
c423335
add two examples and one suggestion
FeynmanZhou Jan 2, 2024
889bb38
Merge branch 'main' of https://github.com/oras-project/oras into erro…
FeynmanZhou Jan 2, 2024
0f75e08
resolve comments and refine spec
FeynmanZhou Jan 2, 2024
4ce6b05
Merge branch 'main' of https://github.com/oras-project/oras into erro…
FeynmanZhou Jan 4, 2024
0de8d59
resolve comments
FeynmanZhou Jan 4, 2024
aaeb6bb
resolve comments
FeynmanZhou Jan 9, 2024
1a575b8
Merge branch 'main' of https://github.com/oras-project/oras into erro…
FeynmanZhou Jan 9, 2024
d8f921b
resolve comments
FeynmanZhou Jan 9, 2024
5568f2c
Update docs/proposals/error-handling-guideline.md
FeynmanZhou Jan 16, 2024
d338fce
Merge branch 'main' into error-guide
Feb 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 42 additions & 5 deletions docs/proposals/error-handling-guideline.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ Fourth, signal-to-noise ratio is crucial. The more irrelevant output you produce

Fifth, CLI program termination should follow the standard [Exit Status conventions](https://www.gnu.org/software/libc/manual/html_node/Exit-Status.html) to report execution status information about success or failure. ORAS returns `EXIT_FAILURE` if and only if ORAS reports one or more errors.

Last, error logs can also be useful for post-mortem debugging, truncate them occasionally so they don't eat up space on disk, and make sure they don't contain ansi color codes. Thereby, error logs can be written to a file.
Last, error logs can also be useful for post-mortem debugging and can also be written to a file, truncate them occasionally and make sure they don't contain ansi color codes.

## Error output recommendation

### Dos

- Provide full description if the user input does not match what ORAS CLI expected. A full description should include the actual input received from the user and expected input
- Use the capital letter ahead of each line of any error message
- Print human readable error message. If the error message is mainly from the server and varies by different servers, tell users that the error response is from server. This implies that users may need to contact server side for troubleshooting.
- Print human readable error message. If the error message is mainly from the server and varies by different servers, tell users that the error response is from server. This implies that users may need to contact server side for troubleshooting
- Provide specific and actionable prompt message with argument suggestion or show the example usage for reference. (e.g, Instead of showing flag or argument options is missing, please provide available argument options and guide users to "--help" to view more examples)
- If the actionable prompt message is too long to show in the CLI output, consider guide users to ORAS user guide or troubleshooting guide with the permanent link.
- If the actionable prompt message is too long to show in the CLI output, consider guide users to ORAS user manual or troubleshooting guide with the versioned permanent link
- If the error message is not enough for troubleshooting, guide users to use "--verbose" to print much more detailed logs
- If the error message from the server side is too generic or has no value, especially in a few edge cases like example 12 and 13 below, consider providing customized and trimmed error logs to make it clearer. The original server logs can be displayed in debug mode
FeynmanZhou marked this conversation as resolved.
Show resolved Hide resolved

### Don'Ts

Expand Down Expand Up @@ -128,7 +129,7 @@ Suggested error message:
$ oras manifest push --oci-layout /sample/images:foobar:mediatype
Error: media type is not recognized.
Usage: oras manifest push [flags] <name>[:<tag>[,<tag>][...]|@<digest>] <file>
You need to specify a valid media type in the manifest JSON or via the "--media-type" flag.
You need to specify a valid media type in the manifest JSON or via the "--media-type" flag
```

#### Example 5: Attach an artifact if the given option is unknown
Expand Down Expand Up @@ -197,7 +198,7 @@ Suggested error message:
```console
$ oras push --annotation "key:value" ghcr.io/library/alpine:3.9
Error: annotation value doesn't match the required format.
Try --annotation "key=value"
Please use the correct format in the flag: --annotation "key=value"
```

#### Example 9: When failed to pull files from a public registry
Expand Down Expand Up @@ -249,6 +250,42 @@ $ oras push localhost:5000/oras:v1 hello.txt
Error: /home/user/hello.txt: no such file or directory
```

#### Example 12: failed to authenticate with registry using an error credential from credential store

Current behavior and output:

```console
$ oras pull localhost:7000/repo:tag --registry-config auth.config
Error: failed to resolve tag: GET "http://localhost:7000/v2/repo/manifests/tag": credential required for basic auth
```

Suggested error message:

```console
$ oras pull localhost:7000/repo:tag --registry-config auth.config
Error: pulling content from localhost:7000/repo:tag failed with status: 401 Unauthorized
FeynmanZhou marked this conversation as resolved.
Show resolved Hide resolved
Please check whether the registry credential stored in the authentication file is correct
```

#### Example 13: failed to resolve the digest with incorrect username or password
FeynmanZhou marked this conversation as resolved.
Show resolved Hide resolved

Current behavior and output:

```console
oras resolve localhost:7000/command/artifacts:foobar -u t -p 2
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from registry: <nil>
```

Suggested error message:

```console
oras resolve localhost:7000/command/artifacts:foobar -u t -p 2
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error: resolving the digest of artifact localhost:7000/command/artifacts:foobar failed with status: 401 Unauthorized
Please use correct username or password
FeynmanZhou marked this conversation as resolved.
Show resolved Hide resolved
```

## Reference
FeynmanZhou marked this conversation as resolved.
Show resolved Hide resolved

Parts of the content are borrowed from these guidelines.
Expand Down