From 63d7aca179195f1361ae2d312f6516f85b4342ae Mon Sep 17 00:00:00 2001 From: huangyi Date: Mon, 13 May 2024 13:48:00 +0800 Subject: [PATCH 1/3] Problem: encrypto_to_validators fail if any validator not registered Solution: - just log the error and continue, more UX friendly. --- x/e2ee/client/cli/encrypt_to_validators.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x/e2ee/client/cli/encrypt_to_validators.go b/x/e2ee/client/cli/encrypt_to_validators.go index 6935923294..484f4718cc 100644 --- a/x/e2ee/client/cli/encrypt_to_validators.go +++ b/x/e2ee/client/cli/encrypt_to_validators.go @@ -2,6 +2,7 @@ package cli import ( "context" + "fmt" "io" "os" @@ -65,7 +66,8 @@ func EncryptToValidatorsCommand() *cobra.Command { for i, key := range rsp.Keys { recipient, err := age.ParseX25519Recipient(key) if err != nil { - return err + fmt.Fprintf(os.Stderr, "failed to parse recipient key: %v\n", err) + continue } recipients[i] = recipient } From 75d09cbdd2cffd8002ba5b87f7671edf62c71db9 Mon Sep 17 00:00:00 2001 From: huangyi Date: Mon, 13 May 2024 13:53:26 +0800 Subject: [PATCH 2/3] improve log --- x/e2ee/client/cli/encrypt_to_validators.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/x/e2ee/client/cli/encrypt_to_validators.go b/x/e2ee/client/cli/encrypt_to_validators.go index 484f4718cc..0ec1a21472 100644 --- a/x/e2ee/client/cli/encrypt_to_validators.go +++ b/x/e2ee/client/cli/encrypt_to_validators.go @@ -64,10 +64,14 @@ func EncryptToValidatorsCommand() *cobra.Command { recipients := make([]age.Recipient, len(recs)) for i, key := range rsp.Keys { + if len(key) == 0 { + fmt.Fprintf(os.Stderr, "missing encryption key for validator %s\n", recs[i]) + continue + } + recipient, err := age.ParseX25519Recipient(key) if err != nil { - fmt.Fprintf(os.Stderr, "failed to parse recipient key: %v\n", err) - continue + return err } recipients[i] = recipient } From f75140bf551f8a68e4762bdec106ed9a40b0d5a3 Mon Sep 17 00:00:00 2001 From: huangyi Date: Mon, 13 May 2024 13:54:17 +0800 Subject: [PATCH 3/3] improve log --- x/e2ee/client/cli/encrypt_to_validators.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x/e2ee/client/cli/encrypt_to_validators.go b/x/e2ee/client/cli/encrypt_to_validators.go index 0ec1a21472..fc30b1953e 100644 --- a/x/e2ee/client/cli/encrypt_to_validators.go +++ b/x/e2ee/client/cli/encrypt_to_validators.go @@ -71,7 +71,8 @@ func EncryptToValidatorsCommand() *cobra.Command { recipient, err := age.ParseX25519Recipient(key) if err != nil { - return err + fmt.Fprintf(os.Stderr, "invalid encryption key for validator %s, %v\n", recs[i], err) + continue } recipients[i] = recipient }