Skip to content

Deletion cascade does not clean up user_s3_permissions #149

Closed

Description

@neuromechanist

Bug

deleteDatasetCascade in backend/src/services/deletion.ts does not include user_s3_permissions in its D1 batch deletion. When a dataset is deleted, orphaned permission rows remain in the table.

Current behavior

The cascade deletes:

  • dataset_versions
  • publication_requests
  • dataset_collaborators
  • datasets

But NOT user_s3_permissions rows where s3_prefix = datasetId.

Expected behavior

Add DELETE FROM user_s3_permissions WHERE s3_prefix = ? to the batch deletion.

Impact

Orphaned permission rows accumulate over time. While not a security risk (the dataset and IAM policy are cleaned up separately), it clutters the permissions table and could cause confusion during auditing.

Fix

Add to the db.batch() call in deleteDatasetCascade:

db.prepare("DELETE FROM user_s3_permissions WHERE s3_prefix = ?").bind(datasetId),

Activity

  1. added
    bug
    on Feb 14, 2026
  2. added 2 commits that reference this issue on Feb 20, 2026
    97146e5
    77bb7bc
  3. added 2 commits that reference this issue on Oct 16, 2026
    4a1d8e9
    fc3f141
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions