secret init and secret vault create ask for the mnemonic and passphrase before refusing a vault that already exists #151

Open
opened 2026-10-13 00:31:00 +02:00 by clawbot · 0 comments
Collaborator

Severity: minor. The user types the mnemonic and a passphrase twice for nothing; the refusal itself is right and nothing is written.

secret init                       # the default vault exists
Initialized secrets manager at: /home/u/.config/berlin.sneak.pkg.secret
Enter your BIP39 mnemonic phrase:
Enter passphrase for unlocker:
Confirm passphrase:
Error: failed to create default vault: vault default already exists

"Initialized" is printed before the refusal too. secret vault create default behaves the same way.

Where.

mnemonic, cleanupMnemonic, err := cli.promptMnemonic()
prompts and
vlt, err := vault.CreateVault(cli.fs, cli.stateDir, "default",
creates;
mnemonic, cleanupMnemonic, err := cli.promptMnemonic()
and
vlt, err := vault.CreateVault(cli.fs, cli.stateDir, name,
; the existence check is inside CreateVault at
exists, err := afero.DirExists(fs, vaultDir)
.

Correct behaviour. Check, under the lock, that the vault does not exist before any prompt, and print "Initialized" only on success.

Definition of done

  • init and vault create on an existing vault fail without prompting.
  • A test runs init on an existing vault with no terminal and no environment variables; before the fix the error is about reading the mnemonic, after it the error says the vault exists.

Model: fable-5-1

Severity: minor. The user types the mnemonic and a passphrase twice for nothing; the refusal itself is right and nothing is written. ``` secret init # the default vault exists Initialized secrets manager at: /home/u/.config/berlin.sneak.pkg.secret Enter your BIP39 mnemonic phrase: Enter passphrase for unlocker: Confirm passphrase: Error: failed to create default vault: vault default already exists ``` "Initialized" is printed before the refusal too. `secret vault create default` behaves the same way. **Where.** https://git.eeqj.de/sneak/secret/src/commit/ef0ae90768c8b18a829033b3ebd4cf98fcaeb3d1/internal/cli/init.go#L103 prompts and https://git.eeqj.de/sneak/secret/src/commit/ef0ae90768c8b18a829033b3ebd4cf98fcaeb3d1/internal/cli/init.go#L139 creates; https://git.eeqj.de/sneak/secret/src/commit/ef0ae90768c8b18a829033b3ebd4cf98fcaeb3d1/internal/cli/vault.go#L268 and https://git.eeqj.de/sneak/secret/src/commit/ef0ae90768c8b18a829033b3ebd4cf98fcaeb3d1/internal/cli/vault.go#L296; the existence check is inside `CreateVault` at https://git.eeqj.de/sneak/secret/src/commit/ef0ae90768c8b18a829033b3ebd4cf98fcaeb3d1/internal/vault/management.go#L247. **Correct behaviour.** Check, under the lock, that the vault does not exist before any prompt, and print "Initialized" only on success. **Definition of done** - `init` and `vault create` on an existing vault fail without prompting. - A test runs `init` on an existing vault with no terminal and no environment variables; before the fix the error is about reading the mnemonic, after it the error says the vault exists. Model: fable-5-1
sneak was assigned by clawbot 2026-10-13 00:31:00 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/secret#151