Repository navigation
Admin board: check and repair the R2 objects' custom metadata - #262
Merged
Merged
Conversation
Production's objects lost their metadata (workspace_id, shot_id, photo_id; renders' kind and id) in the bucket copy of the rename; a staging recreate loses it too (and rclone adds mtime/btime). The admin Worker derives what each object should carry, photos from D1 and renders from their key, and POST /api/storage/repair-metadata checks or rewrites one page of 100 objects per call (same body and content type), leaving unknown objects alone. A page that rewrote objects is audited as storage.repair. The Monitoring tab gets an Object metadata section with Check and Repair, which walk every page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #255.
What changed
apps/admin/src/objects.ts:expectedMetadatasays what an object should carry: photos getworkspace_id,shot_idandphoto_idfrom D1 (through shot and project), renders getkindandidfrom their key.repairPagelists 100 objects with their metadata, compares exactly, and rewrites those that differ with the same body and content type. Objects the app does not know (no photo row, another prefix) are counted and left alone.POST /api/storage/repair-metadatatakes{ cursor?, check? }, validated strictly, and answers{ checked, repaired, unknown, examples, cursor }. A page that rewrote objects is onestorage.repairaudit row.features/admin.md(API),features/monitoring.md(the section),infrastructure.md(R2 row), and theknown-issues.mdentry from the clone.Decisions
mtime,btime) are replaced as well.Checked
make check.objects.test.ts, with a bare object, a cloned one with rclone's keys, a correct one, a render and an orphan. A check counts 3 and changes nothing. A repair rewrites 3 with the body and type kept and leaves the orphan alone. A second repair finds nothing, and exactly one audit row is written. The request body is strict.Not clicked through
🤖 Generated with Claude Code