capgo
capgo copied to clipboard
Manifest cleanup can lose retry source when object delete fails
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:
deleteManifest()loads manifest rows for a deleted version.- It deletes a
public.manifestrow first. - It then checks whether any other row references the same file and calls
s3.deleteObject(). - 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, ands3_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