capgo icon indicating copy to clipboard operation
capgo copied to clipboard

Manifest cleanup can lose retry source when object delete fails

Open digzrow-coder opened this issue 6 months ago • 0 comments

A follow-up from reviewing the soft-delete / hard-delete cleanup path: manifest object cleanup can still lose its retry source when the storage delete fails after the DB row is removed.

Failure mode:

  1. deleteManifest() loads manifest rows for a deleted version.
  2. It deletes a public.manifest row first.
  3. It then checks whether any other row references the same file and calls s3.deleteObject().
  4. If that object delete fails transiently, the manifest row is already gone, so a later cleanup run no longer has a durable DB pointer for retrying the object delete.

I pushed a focused patch here because this repo currently restricts PR creation to collaborators:

https://github.com/digzrow-coder/capgo/commit/7056e77a

Patch summary:

  • check for another manifest row with the same file_hash, file_name, and s3_path
  • delete the storage object before deleting the last manifest DB row
  • keep the manifest row when object deletion fails
  • rethrow cleanup failures so the trigger remains retryable
  • add a regression proving the manifest row is not deleted when the manifest object delete fails

Verification:

bunx vitest run tests/on-version-update-cleanup.unit.test.ts
bunx eslint supabase/functions/_backend/triggers/on_version_update.ts tests/on-version-update-cleanup.unit.test.ts
git diff --check

digzrow-coder avatar May 14 '26 17:05 digzrow-coder