Deleting a space or app group skips the legal-hold check and leaves held files outside the trash #962

Closed
opened 2026-10-18 11:36:06 +00:00 by Cordy · 1 comment
Owner

Found in the #935 research (2026-10-18). Related to #935, but deserves its own tracking because it touches legal holds.

What happens

The space delete in spaces_lifecycle.go deleteSpace moves /spaces/<name> into the trash. The app group delete that also removes the group's space (internal/api/groups.go ~512) does the same. Neither path runs the legal-hold check the trash purge applies. Two cases follow:

  • When the space was renamed and its folder still has the old name, the files stay on disk outside the trash (#935).
  • Held files under a deleted space are therefore neither protected nor visible in Deleted files.

Expected

  • A delete of a space that contains held content is refused, with the existing legal-hold answer.
  • Both delete paths go through the space's own backend folder (the #935 fix).

To do

  1. Route both paths through one helper that resolves the space's backend folder and checks holds.
  2. Test with a held file in a renamed space, on posix and s3.
Found in the #935 research (2026-10-18). Related to #935, but deserves its own tracking because it touches legal holds. ## What happens The space delete in `spaces_lifecycle.go` deleteSpace moves `/spaces/<name>` into the trash. The app group delete that also removes the group's space (`internal/api/groups.go` ~512) does the same. Neither path runs the legal-hold check the trash purge applies. Two cases follow: - When the space was renamed and its folder still has the old name, the files stay on disk outside the trash (#935). - Held files under a deleted space are therefore neither protected nor visible in Deleted files. ## Expected - A delete of a space that contains held content is refused, with the existing `legal-hold` answer. - Both delete paths go through the space's own backend folder (the #935 fix). ## To do 1. Route both paths through one helper that resolves the space's backend folder and checks holds. 2. Test with a held file in a renamed space, on posix and s3.
Author
Owner

Shipped in v0.6.350 (PR #970). Live check on files-bao, 2026-10-19: PASS.

This exercised exactly the reported case: a renamed space whose folder still has its old name.

  1. Created the throwaway space B3hold, uploaded held.txt and put a legal hold on it.
  2. Renamed B3hold to B3hold2. The hold stopped the folder from moving, so the folder still has the old name. The log logged WARN spaces: rename not finished … reason=legal-hold.
  3. Deactivated the space and deleted it: refused with 403 legal-hold. On v0.6.349 this delete was skipped silently and the space was tombstoned with its files left behind.
  4. Lifted the hold and deleted the space again. The whole folder went into Deleted files under the space's current name (/spaces/B3hold2).
  5. Purged it. The log logged spaces: purged space's name is free again.

The hold, the space and the trash entry are all removed again.

Not exercised live: the group delete with ?space=delete. It uses the same helper and is covered by tests.

**Shipped in v0.6.350 (PR #970). Live check on files-bao, 2026-10-19: PASS.** This exercised exactly the reported case: a renamed space whose folder still has its old name. 1. Created the throwaway space B3hold, uploaded `held.txt` and put a legal hold on it. 2. Renamed B3hold to B3hold2. The hold stopped the folder from moving, so the folder still has the old name. The log logged WARN `spaces: rename not finished … reason=legal-hold`. 3. Deactivated the space and deleted it: refused with **403 `legal-hold`**. On v0.6.349 this delete was skipped silently and the space was tombstoned with its files left behind. 4. Lifted the hold and deleted the space again. The whole folder went into Deleted files under the space's current name (`/spaces/B3hold2`). 5. Purged it. The log logged `spaces: purged space's name is free again`. The hold, the space and the trash entry are all removed again. **Not exercised live:** the group delete with `?space=delete`. It uses the same helper and is covered by tests.
Cordy closed this issue 2026-10-19 20:13:02 +00:00
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#962
No description provided.