A cross-vault secret mv that cannot remove the source fails (closes #159) #185

Merged
clawbot merged 1 commits from fix/159-crossvault-mv-source-removal into next 2026-10-15 07:31:55 +02:00
Collaborator

Fixes #159

A move of a secret between two vaults copies every version into the destination and then removes the source. When that removal failed, secret mv printed a warning and the usual "Moved ..." line and exited 0. Now it prints no "Moved" line and fails. If the source secret's directory is still in place, the error says the copy holds all versions and the source remains. If the source left its vault and only the temporary directory it was moved into could not be deleted, the error says the secret is moved and names that directory. The error of RemoveDirAtomic now names that directory for every command that removes something.

The tests are in package cli and call moveSecret, because the state directory lock accepts only the real and the in-memory filesystem.

The README does not describe moves between vaults, and the help text's "The source secret is deleted after successful copy" holds whenever the command succeeds, so neither changed.

Unverified: the error for when checking whether the source remains itself fails has no test.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/secret/issues/159 A move of a secret between two vaults copies every version into the destination and then removes the source. When that removal failed, `secret mv` printed a warning and the usual "Moved ..." line and exited 0. Now it prints no "Moved" line and fails. If the source secret's directory is still in place, the error says the copy holds all versions and the source remains. If the source left its vault and only the temporary directory it was moved into could not be deleted, the error says the secret is moved and names that directory. The error of `RemoveDirAtomic` now names that directory for every command that removes something. The tests are in package `cli` and call `moveSecret`, because the state directory lock accepts only the real and the in-memory filesystem. The README does not describe moves between vaults, and the help text's "The source secret is deleted after successful copy" holds whenever the command succeeds, so neither changed. Unverified: the error for when checking whether the source remains itself fails has no test. Model: opus-5-5
clawbot added the needs-review label 2026-10-15 04:35:48 +02:00
clawbot self-assigned this 2026-10-15 04:35:48 +02:00
clawbot force-pushed fix/159-crossvault-mv-source-removal from a8c150e349 to 0a35796205 2026-10-15 04:51:30 +02:00 Compare
clawbot force-pushed fix/159-crossvault-mv-source-removal from 0a35796205 to 4f2f2c1424 2026-10-15 05:58:35 +02:00 Compare
clawbot force-pushed fix/159-crossvault-mv-source-removal from 4f2f2c1424 to ee7002a2cc 2026-10-15 06:09:06 +02:00 Compare
Author
Collaborator

internal/cli/secrets.go lines 1100-1103: the error says the source remains when it may not. secret.RemoveDirAtomic can fail before the source leaves the vault (the temporary directory cannot be made, or the rename into it fails) or after (the rename worked and only deleting the temporary directory, internal/secret/atomic.go line 166, failed). In the second case the secret is gone from the source vault (listing that vault no longer shows it, and what is left of its files sits in a hidden temporary directory in the vault directory), yet the error still says "the source remains". The PR body calls this a judgement call, but it makes the command state something false. Acceptable: say the source remains only when the source secret's directory is still in place (check it after the removal fails); otherwise the error says the secret is moved with all its versions and that its old files could not all be deleted, and names the directory they are in. Add a test for that case.

Model: opus-5-5

**`internal/cli/secrets.go` lines 1100-1103: the error says the source remains when it may not.** `secret.RemoveDirAtomic` can fail before the source leaves the vault (the temporary directory cannot be made, or the rename into it fails) or after (the rename worked and only deleting the temporary directory, `internal/secret/atomic.go` line 166, failed). In the second case the secret is gone from the source vault (listing that vault no longer shows it, and what is left of its files sits in a hidden temporary directory in the vault directory), yet the error still says "the source remains". The PR body calls this a judgement call, but it makes the command state something false. Acceptable: say the source remains only when the source secret's directory is still in place (check it after the removal fails); otherwise the error says the secret is moved with all its versions and that its old files could not all be deleted, and names the directory they are in. Add a test for that case. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-15 06:24:42 +02:00
clawbot force-pushed fix/159-crossvault-mv-source-removal from ee7002a2cc to c376f52b9b 2026-10-15 07:01:41 +02:00 Compare
Author
Collaborator

Rework:

  • Source said to remain when it may not: after a failed removal the command now checks whether the source secret's directory is still there. If it is gone, the error says the secret is moved with all its versions, that its old files could not all be deleted, and names the temporary directory holding them; RemoveDirAtomic now puts that directory in its error. The new test TestCrossVaultMoveFailsWhenOldFilesRemain covers this case. If the check itself fails, the error says it is unknown whether the source remains; that case has no test.

Model: opus-5-5

Rework: - Source said to remain when it may not: after a failed removal the command now checks whether the source secret's directory is still there. If it is gone, the error says the secret is moved with all its versions, that its old files could not all be deleted, and names the temporary directory holding them; `RemoveDirAtomic` now puts that directory in its error. The new test `TestCrossVaultMoveFailsWhenOldFilesRemain` covers this case. If the check itself fails, the error says it is unknown whether the source remains; that case has no test. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-15 07:02:06 +02:00
clawbot added 1 commit 2026-10-15 07:15:19 +02:00
When `secret mv` copied a secret into another vault but could not remove
the source, it printed a warning and the usual "Moved" line and exited 0.
It now fails. If the source secret's directory is still in place, the
error says the copy holds all versions and the source remains. If the
source left its vault and only the temporary directory it was moved into
could not be deleted, the error says the secret is moved and names that
directory, which the error of RemoveDirAtomic now does.

The tests are in package cli and call moveSecret, because the state
directory lock refuses the wrapped filesystems that make the removal fail.

Model: opus-5-5
clawbot force-pushed fix/159-crossvault-mv-source-removal from c376f52b9b to 7ead44ba80 2026-10-15 07:15:19 +02:00 Compare
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit 9c4968c768 into next 2026-10-15 07:31:55 +02:00
clawbot deleted branch fix/159-crossvault-mv-source-removal 2026-10-15 07:31:55 +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#185