notaryproject / notation

A CLI tool to sign and verify artifacts
https://notaryproject.dev/
Apache License 2.0
340 stars 84 forks source link

fix: improve error message for plugin #870

Closed JeyJeyGao closed 8 months ago

JeyJeyGao commented 8 months ago

Resolves #867 Signed-off-by: Junjie Gao junjiegao@microsoft.com

codecov-commenter commented 8 months ago

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (ee72394) 65.14% compared to head (b2e8418) 64.93%.

Files Patch % Lines
cmd/notation/plugin/install.go 25.00% 4 Missing and 2 partials :warning:
cmd/notation/plugin/list.go 0.00% 5 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #870 +/- ## ========================================== - Coverage 65.14% 64.93% -0.22% ========================================== Files 45 45 Lines 2717 2729 +12 ========================================== + Hits 1770 1772 +2 - Misses 787 795 +8 - Partials 160 162 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Two-Hearts commented 8 months ago

When running command on a malformed plugin executable file on Windows: ./notation.exe plugin install --file ./malformed-plugin/azure-kv/notation-azure-kv.exe, the command returns following error message:

Error: plugin installation failed: failed to get metadata of new plugin: failed to execute the get-plugin-metadata command for plugin azure-kv: fork/exec ./malformed-plugin/azure-kv/notation-azure-kv.exe: This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher..
Please ensure the plugin is executable and meet the installation requirements on the windows/amd64.

On linux:

Error: plugin installation failed: failed to get metadata of new plugin: failed to execute the get-plugin-metadata command for plugin azure-kv: fork/exec test-plugin/malformed-plugin/azure-kv/notation-azure-kv: exec format error.
Please ensure the plugin is executable and meet the installation requirements on the linux/amd64.

These error messages are quite verbose though, can we improve them? (contents starting with fork/exec are already in the DEBUG log)

JeyJeyGao commented 8 months ago

When running command on a malformed plugin executable file on Windows: ./notation.exe plugin install --file ./malformed-plugin/azure-kv/notation-azure-kv.exe, the command returns following error message:

Error: plugin installation failed: failed to get metadata of new plugin: failed to execute the get-plugin-metadata command for plugin azure-kv: fork/exec ./malformed-plugin/azure-kv/notation-azure-kv.exe: This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher..
Please ensure the plugin is executable and meet the installation requirements on the windows/amd64.

On linux:

Error: plugin installation failed: failed to get metadata of new plugin: failed to execute the get-plugin-metadata command for plugin azure-kv: fork/exec test-plugin/malformed-plugin/azure-kv/notation-azure-kv: exec format error.
Please ensure the plugin is executable and meet the installation requirements on the linux/amd64.

These error messages are quite verbose though, can we improve them? (contents starting with fork/exec are already in the DEBUG log)

Updated to:

./bin/notation plugin install --file ~/download/notation-azure-kv_1.0.1_darwin_amd64.tar.gz -d
DEBU[2024-01-18T12:55:26+08:00] Extracting file notation-azure-kv...         
DEBU[2024-01-18T12:55:26+08:00] Extracting file LICENSE...                   
DEBU[2024-01-18T12:55:26+08:00] Installing plugin from plugin path /tmp/notation-plugin2182206927 
DEBU[2024-01-18T12:55:26+08:00] Plugin get-plugin-metadata request: {}       
ERRO[2024-01-18T12:55:26+08:00] plugin get-plugin-metadata execution status: fork/exec /tmp/notation-plugin2182206927/notation-azure-kv: exec format error 
Error: plugin installation failed: failed to get metadata of new plugin: failed to execute the get-plugin-metadata command for plugin azure-kv.
Please ensure the plugin is executable and meet the installation requirements on the linux/amd64.