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

Improve error messages for notation CLI #128

Closed
nelson-wu opened this issue Nov 12, 2021 · 14 comments
Closed

Improve error messages for notation CLI #128

nelson-wu opened this issue Nov 12, 2021 · 14 comments
Assignees
Labels
error message Issues related to error message improvement UX User experience changes
Milestone

Comments

@nelson-wu
Copy link

Some examples:

$ notation cert generate-test
2021/11/12 13:53:30 missing certificate hosts

Perhaps flesh this out more with examples, similar to az cli

> az acr import -n 
the following arguments are required: --source

TRY THIS:
az acr import --name MyRegistry --source docker.io/library/hello-world:latest --image targetrepository:targettag
Import an image from a public repository on Docker Hub. The image uses the specified repository and tag names.

az acr import --name MyRegistry --source sourcerepository:sourcetag --image targetrepository:targettag --registry /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/sourceResourceGroup/providers/Microsoft.ContainerRegistry/registries/sourceRegistry
Import an image from an Azure container registry in a different subscription.

https://docs.microsoft.com/en-US/cli/azure/acr#az_acr_import
Read more about the command in reference docs
@dtzar dtzar added the supportability Need support from the community label Jul 11, 2022
@dtzar dtzar added this to the RC-1 milestone Jul 11, 2022
@NiazFK NiazFK modified the milestones: RC-1, Discuss Jul 14, 2022
@iamsamirzon iamsamirzon added the UX User experience changes label Jul 15, 2022
@dtzar dtzar moved this to In Progress in Notary Project Planning Board Jul 22, 2022
@dtzar
Copy link
Contributor

dtzar commented Jul 23, 2022

We should get better error messages as a result of moving to cobra, but should evaluate the experience of error messages after the PR merges #255

@dtzar
Copy link
Contributor

dtzar commented Jul 28, 2022

Let's also in this improvement make sure the CLIs exit with proper exit code (non zero for failures) https://github.com/urfave/cli/blob/master/docs/v2/manual.md#exit-code

@iamsamirzon
Copy link
Contributor

@dtzar - I created a new issue related to helping users deal with CLI errors. Refer #300

@yizha1 yizha1 modified the milestones: Discuss, RC-2 Aug 23, 2022
@priteshbandi
Copy link
Contributor

Some examples of inappropriate errors:

Missing trustpolicy.json file

➜  notation git:(main) ✗ ./notation verify $IMAGE
Resolved artifact tag `v1` to digest `sha256:36ca4d6834ed680362327811238b97c687e77c5cf4a04a74d0853d3c0c17e059` before verification.
Warning: The resolved digest may not point to the same signed artifact, since tags are mutable.
Error: open /Users/pritesb/Library/Application Support/notation/trustpolicy.json: no such file or directory

Empty trustpolicy.json file

➜  notation git:(main) ✗ ./notation verify $IMAGE
Resolved artifact tag `v1` to digest `sha256:36ca4d6834ed680362327811238b97c687e77c5cf4a04a74d0853d3c0c17e059` before verification.
Warning: The resolved digest may not point to the same signed artifact, since tags are mutable.
Error: EOF

trustpolicy.json file content: {}

➜  notation git:(main) ✗ ./notation verify $IMAGE
Resolved artifact tag `v1` to digest `sha256:36ca4d6834ed680362327811238b97c687e77c5cf4a04a74d0853d3c0c17e059` before verification.
Warning: The resolved digest may not point to the same signed artifact, since tags are mutable.
Error: trust policy document uses unsupported version ""

trustpolicy.json file content: hola

➜  notation git:(main) ✗ ./notation verify $IMAGE
Resolved artifact tag `v1` to digest `sha256:36ca4d6834ed680362327811238b97c687e77c5cf4a04a74d0853d3c0c17e059` before verification.
Warning: The resolved digest may not point to the same signed artifact, since tags are mutable.
Error: invalid character 'h' looking for beginning of value

@yizha1 yizha1 moved this from In Progress to Todo in Notary Project Planning Board Dec 8, 2022
@yizha1 yizha1 moved this from Todo to In Progress in Notary Project Planning Board Dec 14, 2022
@patrickzheng200
Copy link
Contributor

patrickzheng200 commented Dec 19, 2022

Error: open /Users/pritesb/Library/Application Support/notation/trustpolicy.json: no such file or directory

@priteshbandi Is there any concern/suggestion regarding this error message? Since user needs to manually set up the trustpolicy.json file in current notation version, I think we need to explicitly print out the path when the file is missing.

priteshbandi pushed a commit to notaryproject/notation-go that referenced this issue Dec 20, 2022
This PR adds more logs to the library and improves error messages.

This PR intends to resolve following issues:
notaryproject/notation#462
notaryproject/notation#128 -> comments related
to trust policy

Signed-off-by: Patrick Zheng <[email protected]>
@patrickzheng200
Copy link
Contributor

Closing this issue as it's resolved.

Repository owner moved this from In Progress to Done in Notary Project Planning Board Dec 20, 2022
@priteshbandi priteshbandi reopened this Dec 21, 2022
Repository owner moved this from Done to In Progress in Notary Project Planning Board Dec 21, 2022
@priteshbandi
Copy link
Contributor

priteshbandi commented Dec 21, 2022

Reopening as are still inappropriate error messages

  • Notation not properly throwing the error from the plugin. The error is coming from this line. stderr needs to be converted to string from []byte before logging.

@yizha1
Copy link
Contributor

yizha1 commented Jan 3, 2023

Reopening as are still inappropriate error messages

  • Notation not properly throwing the error from the plugin. The error is coming from this line. stderr needs to be converted to string from []byte before logging.

@priteshbandi Is this issue solved by PR notaryproject/notation-go#236?

@yizha1
Copy link
Contributor

yizha1 commented Feb 17, 2023

@priteshbandi could you confirm whether this issue was solved and released in rc.2? Thanks.

@priteshbandi priteshbandi reopened this Feb 28, 2023
@github-project-automation github-project-automation bot moved this from Done to In Progress in Notary Project Planning Board Feb 28, 2023
@priteshbandi
Copy link
Contributor

priteshbandi commented Feb 28, 2023

Test result with notation rc2 build

➜  notation git:(main) ✗ ./notation cert generate-test
Error: missing certificate common_name
➜  notation git:(main) ✗ echo $?
1
➜  notation git:(main) ✗ ./notation cert generate-test --help
Generate a test RSA key and a corresponding self-signed certificate

Example - Generate a test RSA key and a corresponding self-signed certificate named "wabbit-networks.io":
  notation cert generate-test "wabbit-networks.io"

Example - Generate a test RSA key and a corresponding self-signed certificate, set RSA key as a default signing key:
  notation cert generate-test --default "wabbit-networks.io"

Usage:
  notation certificate generate-test [flags] <common_name>

Flags:
  -b, --bits int   RSA key bits (default 2048)
      --default    mark as default signing key
➜  notation git:(main) ✗ ./notation verify $IMAGE
Error: open /Users/pritesb/Library/Application Support/notation/trustpolicy.json: no such file or directory

➜  notation git:(main) ✗ ./notation verify $IMAGE
Error: malformed trustpolicy.json file

➜  notation git:(main) ✗ ./notation verify $IMAGE
Error: trust policy document is missing or has empty version, it must be specified

➜  notation git:(main) ✗ ./notation verify $IMAGE
Error: malformed trustpolicy.json file

@priteshbandi
Copy link
Contributor

priteshbandi commented Feb 28, 2023

Apart from below error everything looks to be fixed

Error: open /Users/pritesb/Library/Application Support/notation/trustpolicy.json: no such file or directory

@priteshbandi Is there any concern/suggestion regarding this error message? Since user needs to manually set up the trustpolicy.json file in current notation version, I think we need to explicitly print out the path when the file is missing.
The error message

IMO the error message Error: open /Users/pritesb/Library/Application Support/notation/trustpolicy.json: no such file or directory doesn't gives actionable user friendly message such as Trust policy is not present, please create trust policy at /Users/pritesb/Library/Application Support/notation/trustpolicy.json

@vaninrao10 vaninrao10 modified the milestones: RC-2, RC-4, RC-3 Feb 28, 2023
priteshbandi pushed a commit to notaryproject/notation-go that referenced this issue Mar 3, 2023
This PR improves the error message for a missing trustpolicy file [notaryproject/notation/#128](notaryproject/notation#128 (comment)). This is the output when the trustpolicy is missing:
```
c889f3b9d811:notation kodysk$ ./bin/notation verify $IMAGE
Error: Trust policy is not present, please create trust policy at /Users/kodysk/Library/Application Support/notation/trustpolicy.json
```

Signed-off-by: Kody Kimberl [email protected]
@yizha1 yizha1 modified the milestones: RC-3, Discuss Apr 10, 2023
@yizha1 yizha1 modified the milestones: Discuss, 1.2.0 Apr 9, 2024
@yizha1
Copy link
Contributor

yizha1 commented Apr 9, 2024

Linked to error message improvements work planned in v1.2.0, #824.

@yizha1 yizha1 removed the supportability Need support from the community label Apr 9, 2024
@yizha1 yizha1 assigned Two-Hearts and unassigned patrickzheng200 Jul 12, 2024
@yizha1 yizha1 added the error message Issues related to error message improvement label Jul 12, 2024
@Two-Hearts
Copy link
Contributor

Test result with Notation CLI v1.2.0-beta.1:

notation. verify $IMAGE
Error: trust policy is not present. To create a trust policy, see: https://notaryproject.dev/docs/quickstart/#create-a-trust-policy

@Two-Hearts
Copy link
Contributor

Closing as this issue has been completed.

@github-project-automation github-project-automation bot moved this from In Progress to Done in Notary Project Planning Board Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error message Issues related to error message improvement UX User experience changes
Projects
Status: Done
Development

No branches or pull requests

9 participants