1 Commits
Author SHA1 Message Date
sneak 4ebd36fd6b Commands fail when currentvault names no vault (closes #156)
check / check (push) Canceled after 0s
An empty currentvault, or one naming a vault that does not exist, made
`secret list` report an empty vault with exit 0 and `secret add` fail on a
missing directory. ResolveVaultSymlink now refuses an empty or invalid
name, or one with no directory under vaults.d, with an error that wraps
ErrVaultNotFound, names the file and says to run
`secret vault select <name>`. Every command that uses the current vault
gets it; `secret vault list` and `secret info` still run.

newSizeTestVault wrote a full path into currentvault, which resolved only
because the last path element was taken as the name; it now relies on
CreateVault selecting the vault.

Model: opus-5-5
2026-10-15 04:48:32 +00:00
2 changed files with 9 additions and 7 deletions
+2 -1
View File
@@ -117,7 +117,8 @@ are allowed, and a name must not be empty, `.` or `..`.
Switches to the specified vault for subsequent operations. When `currentvault` Switches to the specified vault for subsequent operations. When `currentvault`
is empty or names a vault that does not exist, every command that uses the is empty or names a vault that does not exist, every command that uses the
current vault fails with an error that names the file and says to run current vault fails with an error that names the file and says to run
`secret vault select <name>`; `secret vault list` still lists the vaults. `secret vault select <name>`. `secret vault list` still lists the vaults, and
`secret info` still runs; both show no vault as current.
#### `secret vault remove <name> [--force]` / `secret vault rm` ⚠️ 🛑 #### `secret vault remove <name> [--force]` / `secret vault rm` ⚠️ 🛑
+7 -6
View File
@@ -17,15 +17,16 @@ import (
// TestListFailsWhenCurrentVaultDoesNotExist is a regression test for // TestListFailsWhenCurrentVaultDoesNotExist is a regression test for
// https://git.eeqj.de/sneak/secret/issues/156, where a currentvault file // https://git.eeqj.de/sneak/secret/issues/156, where a currentvault file
// that was empty, or named a vault that does not exist, made `secret list` // that was empty, held an invalid vault name, or named a vault that does
// report an empty vault. Listing must fail with an error that names the // not exist, made `secret list` report an empty vault. Listing must fail
// file and says to run `secret vault select`, `secret vault list` must // with an error that names the file and says to run `secret vault select`,
// still list the vaults, and selecting a vault must make listing work // `secret vault list` must still list the vaults, and selecting a vault
// again. // must make listing work again. The name "." would make vaults.d itself the
// vault, and "../vaults.d/work" would reach the vault work by a path.
func TestListFailsWhenCurrentVaultDoesNotExist(t *testing.T) { func TestListFailsWhenCurrentVaultDoesNotExist(t *testing.T) {
t.Parallel() t.Parallel()
for _, name := range []string{"", "gone"} { for _, name := range []string{"", ".", "../vaults.d/work", "gone"} {
t.Run(strconv.Quote(name), func(t *testing.T) { t.Run(strconv.Quote(name), func(t *testing.T) {
t.Parallel() t.Parallel()