Backport Detect errors when writing totp keys to storage into release/2.x.x+ent into ce/release/2.x.x (#14786)

Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>
This commit is contained in:
Vault Automation 2026-05-13 15:18:14 -06:00 committed by GitHub
parent b62aa75129
commit af9b72717c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

3
changelog/_14778.txt Normal file
View file

@ -0,0 +1,3 @@
```release-note:bug
core: Fix failure to detect errors during storage writes of totp keys.
```

View file

@ -1097,13 +1097,13 @@ func (c *Core) PersistTOTPKey(ctx context.Context, methodID, entityID, key strin
}
val, err := jsonutil.EncodeJSON(ks)
if err != nil {
return err
return fmt.Errorf("error encoding TOTP key: %w", err)
}
if c.barrier.Put(ctx, &logical.StorageEntry{
if err := c.barrier.Put(ctx, &logical.StorageEntry{
Key: fmt.Sprintf("%s%s/%s", mfaTOTPKeysPrefix, methodID, entityID),
Value: val,
}); err != nil {
return err
return fmt.Errorf("error persisting TOTP key to storage: %w", err)
}
return nil
}