Skip to content

Commit

Permalink
fix: more informative error (sigstore#1778)
Browse files Browse the repository at this point in the history
When running the attach attestation command with empty file input the cli returns hard to understand output like:

```
file name too long
Using payload from: filename.json
Error: unexpected end of JSON input
main.go:46: error during command execution: unexpected end of JSON input
```

By some investigation I found out that attestation file was empty, yes this is a user-error, so I recon it could be more informative as it throws the error while parsing the input making the real error a bit shaded.

Signed-off-by: ybelMekk <youssef.bel.mekki@nav.no>
  • Loading branch information
ybelMekk authored and mlieberman85 committed May 6, 2022
1 parent 963f5be commit 69d51f0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/cosign/cli/attach/attestation.go
Expand Up @@ -42,6 +42,10 @@ func AttestationCmd(ctx context.Context, regOpts options.RegistryOptions, signed
return err
}

if len(payload) == 0 {
return fmt.Errorf("%s payload is empty", signedPayload)
}

env := ssldsse.Envelope{}
if err := json.Unmarshal(payload, &env); err != nil {
return err
Expand Down

0 comments on commit 69d51f0

Please sign in to comment.