anchore / anchore-cli

Simple command-line client to the Anchore Engine service
Apache License 2.0
114 stars 55 forks source link

[Enhancement] Improve error message detail when adding policy #31

Closed akerge closed 4 years ago

akerge commented 5 years ago

Thanks for all the work you've put in!

Please add more detail when anchore-cli encounters an error when adding a custom policy.

Current output: Detail: 'id' is a required property

Could be Detail: required property 'id' is missing from line 7

Currently it's difficult to troubleshoot where exactly is the 'id' missing from.

alfredodeza commented 4 years ago

@akerge this is going to be a bit tricky to include line numbers. I agree that the wording can be improved though!

When the JSON file is received by anchore-cli it gets sent over an HTTP request to a separate service that does the validation, and upon failure, it responds with the validation issue. The services does not see an actual file, it received the JSON. So it isn't feasible to add a line number.

What I think we can do here is to add an additional message, like a hint, based on the validation failure. Something like this:

Detail: 'id' is a required property
Hint: The 'id' key is not present in the JSON file with the custom policy, make sure this key is present:
    {
        "id": "xxxxx-xxx-xx-xxxx",
        ...
    }
akerge commented 4 years ago

Thanks!