Add secret.Warn() calls for all silent anomalous conditions
Audit of the codebase found 9 locations where errors or anomalous conditions were silently swallowed or only logged via Debug(). Users should be informed when something unexpected happens, even if the program can continue. Changes: - DetermineStateDir: warn on config dir fallback to ~/.config - info_helper: warn when vault/secret stats cannot be read - unlockers list: warn on metadata read/parse failures (fixes FIXMEs) - unlockers list: warn on fallback ID generation - checkUnlockerExists: warn on errors during duplicate checking - completions: warn on unlocker metadata read/parse failures - version list: upgrade metadata load failure from Debug to Warn - secrets: upgrade file close failure from Debug to Warn - version naming: warn on malformed version directory names Closes #19
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"git.eeqj.de/sneak/secret/internal/secret"
|
||||
"github.com/spf13/afero"
|
||||
)
|
||||
|
||||
@@ -28,6 +29,8 @@ func gatherVaultStats(
|
||||
// Count secrets in this vault
|
||||
secretEntries, err := afero.ReadDir(fs, secretsPath)
|
||||
if err != nil {
|
||||
secret.Warn("Could not read secrets directory for vault", "vault", vaultEntry.Name(), "error", err)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -43,6 +46,8 @@ func gatherVaultStats(
|
||||
versionsPath := filepath.Join(secretPath, "versions")
|
||||
versionEntries, err := afero.ReadDir(fs, versionsPath)
|
||||
if err != nil {
|
||||
secret.Warn("Could not read versions directory for secret", "secret", secretEntry.Name(), "error", err)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user