From 6b4e4bcf96e9552ca09ac164665c97e4f0f17707 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 6 Aug 2020 17:40:14 -0500 Subject: [PATCH] Fail Immediately if Importing Accounts from Empty Directory (#6915) * fail on import from empty directory * Merge refs/heads/master into fail-on-empty-dir --- validator/accounts/v2/accounts_import.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/validator/accounts/v2/accounts_import.go b/validator/accounts/v2/accounts_import.go index 3d905abcb..3260baa87 100644 --- a/validator/accounts/v2/accounts_import.go +++ b/validator/accounts/v2/accounts_import.go @@ -74,6 +74,9 @@ func ImportAccount(cliCtx *cli.Context) error { if err != nil { return errors.Wrap(err, "could not read dir") } + if len(files) == 0 { + return fmt.Errorf("directory %s has no files, cannot import from it", keysDir) + } for i := 0; i < len(files); i++ { if files[i].IsDir() { continue