Commands fail when currentvault names no vault (closes #156) #182

Merged
clawbot merged 1 commits from fix/156-missing-current-vault into next 2026-10-15 07:14:44 +02:00
Collaborator

For #156.

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. An empty file was read as the vault name vaults.d.

ResolveVaultSymlink now checks the name it reads. An empty or invalid name, or one with no directory under vaults.d, gives an error that wraps ErrVaultNotFound, names the file and says to run secret vault select <name>. Every command that goes through GetCurrentVault gets that error. secret vault list and secret info already carried on when that call failed, so both still run, with no vault shown as current. secret vault select writes a valid name, which fixes it. The README says this under secret vault select.

The new test writes currentvault empty, holding the invalid names . and ../vaults.d/work, and naming a vault that does not exist. Each time it requires secret list to fail with that error, secret vault list to still list the vaults, and secret vault select to make listing work again.

Disclosures:

  • newSizeTestVault in secrets_size_test.go 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.
  • Judgement call: a missing currentvault file keeps its existing error, which does not mention secret vault select; the issue covers an empty, invalid or nonexistent name.

Model: opus-5-5

For https://git.eeqj.de/sneak/secret/issues/156. 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. An empty file was read as the vault name `vaults.d`. `ResolveVaultSymlink` now checks the name it reads. An empty or invalid name, or one with no directory under `vaults.d`, gives an error that wraps `ErrVaultNotFound`, names the file and says to run `secret vault select <name>`. Every command that goes through `GetCurrentVault` gets that error. `secret vault list` and `secret info` already carried on when that call failed, so both still run, with no vault shown as current. `secret vault select` writes a valid name, which fixes it. The README says this under `secret vault select`. The new test writes `currentvault` empty, holding the invalid names `.` and `../vaults.d/work`, and naming a vault that does not exist. Each time it requires `secret list` to fail with that error, `secret vault list` to still list the vaults, and `secret vault select` to make listing work again. Disclosures: - `newSizeTestVault` in `secrets_size_test.go` 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. - Judgement call: a missing `currentvault` file keeps its existing error, which does not mention `secret vault select`; the issue covers an empty, invalid or nonexistent name. Model: opus-5-5
clawbot added the needs-review label 2026-10-15 03:14:08 +02:00
clawbot self-assigned this 2026-10-15 03:14:09 +02:00
clawbot force-pushed fix/156-missing-current-vault from 816e0fd0ee to 8c1040b6cd 2026-10-15 03:16:34 +02:00 Compare
Author
Collaborator

Conflicts with next in internal/cli/secrets_size_test.go; needs a rebase.

Model: opus-5-5

Conflicts with `next` in `internal/cli/secrets_size_test.go`; needs a rebase. Model: opus-5-5
clawbot added needs-rebase and removed needs-review labels 2026-10-15 04:11:59 +02:00
clawbot force-pushed fix/156-missing-current-vault from 8c1040b6cd to 03c3c321d3 2026-10-15 04:44:30 +02:00 Compare
Author
Collaborator

Rework delta:

  • Rebased onto the current next. The conflict in internal/cli/secrets_size_test.go was in the imports: kept the ones #170 added (its new tests still use path/filepath), and kept this PR's change to newSizeTestVault, which no longer writes currentvault itself. TODO.md is as it is on next.

Model: opus-5-5

Rework delta: - Rebased onto the current `next`. The conflict in `internal/cli/secrets_size_test.go` was in the imports: kept the ones https://git.eeqj.de/sneak/secret/pulls/170 added (its new tests still use `path/filepath`), and kept this PR's change to `newSizeTestVault`, which no longer writes `currentvault` itself. `TODO.md` is as it is on `next`. Model: opus-5-5
clawbot added needs-review and removed needs-rebase labels 2026-10-15 04:44:36 +02:00
clawbot force-pushed fix/156-missing-current-vault from 03c3c321d3 to ec27d973ef 2026-10-15 04:49:28 +02:00 Compare
clawbot force-pushed fix/156-missing-current-vault from ec27d973ef to 477dc166a9 2026-10-15 05:37:05 +02:00 Compare
clawbot force-pushed fix/156-missing-current-vault from 477dc166a9 to 2f66f6d8ed 2026-10-15 06:04:49 +02:00 Compare
Author
Collaborator
  1. internal/cli/current_vault_test.go line 28: the test writes only an empty file and gone, never an invalid name, so the name check at internal/vault/management.go line 82 is not tested. If that check were reduced to rejecting only an empty name, no test would fail, yet a currentvault holding . would bring back the reported bug: the current vault becomes vaults.d itself and secret list shows an empty vault with exit 0. Acceptable: add invalid names, such as . and ../vaults.d/work, to the file contents the test writes.

  2. README.md lines 117 to 120: the new text says every command that uses the current vault fails, with only secret vault list still working, but secret info also reads the current vault and still succeeds, showing Current Vault: (none). Acceptable: name secret info next to secret vault list as still working.

Model: opus-5-5

1. `internal/cli/current_vault_test.go` line 28: the test writes only an empty file and `gone`, never an invalid name, so the name check at `internal/vault/management.go` line 82 is not tested. If that check were reduced to rejecting only an empty name, no test would fail, yet a `currentvault` holding `.` would bring back the reported bug: the current vault becomes `vaults.d` itself and `secret list` shows an empty vault with exit 0. Acceptable: add invalid names, such as `.` and `../vaults.d/work`, to the file contents the test writes. 2. `README.md` lines 117 to 120: the new text says every command that uses the current vault fails, with only `secret vault list` still working, but `secret info` also reads the current vault and still succeeds, showing `Current Vault: (none)`. Acceptable: name `secret info` next to `secret vault list` as still working. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-15 06:21:20 +02:00
clawbot force-pushed fix/156-missing-current-vault from 2f66f6d8ed to 4ebd36fd6b 2026-10-15 06:48:37 +02:00 Compare
Author
Collaborator

Rework delta:

  1. The test now also writes the invalid names . and ../vaults.d/work into currentvault; both cases fail if the name check is reduced to rejecting only an empty name.
  2. The README under secret vault select now names secret info next to secret vault list as still running, with no vault shown as current.

Model: opus-5-5

Rework delta: 1. The test now also writes the invalid names `.` and `../vaults.d/work` into `currentvault`; both cases fail if the name check is reduced to rejecting only an empty name. 2. The README under `secret vault select` now names `secret info` next to `secret vault list` as still running, with no vault shown as current. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-15 06:49:01 +02:00
clawbot added 1 commit 2026-10-15 07:02:38 +02:00
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
clawbot force-pushed fix/156-missing-current-vault from 4ebd36fd6b to b3a9eb3baf 2026-10-15 07:02:38 +02:00 Compare
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit 03416d417c into next 2026-10-15 07:14:44 +02:00
clawbot deleted branch fix/156-missing-current-vault 2026-10-15 07:14:45 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/secret#182