Fix project rename leaving documentation unreachable (fixes #129) #130
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
qwc-open/asiakirjat!130
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/rename-storage-divorce"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #129.
The bug
MoveProjecttreated a missing source directory as success:Service.Updatethen committed the database rename believing the files had moved. The slug and the on-disk directory were now permanently divorced, and because serving recomputesVersionPath(slug, tag)from the slug (internal/handler/version.go:52), every document 404'd.Reproduced at the handler level, matching the issue report line for line:
Renaming back appears to fix it only because the files never moved.
Why it survived the #122 fix
PR #123 corrected the forward path but never repaired the projects #122 had already broken. Before v0.8.2 a rename moved no files at all, so any project renamed in that era has
DB slug != on-disk directory name. Renaming such a project now finds nothing atProjectPath(oldSlug), hits the silent no-op, and re-breaks it. Triage of the original #122 — renaming back and forth — is exactly what leaves projects in that state.Ruled out along the way: storage is a single shared instance (no root mismatch), and v0.8.2 genuinely contains the #123 fix (
git merge-baseconfirms). Six realistic variants all pass unmodified — custom visibility, multi-version, double rename, the/latest/permalink, service-created projects, and an editor renaming their own project (PR #118'sCanManagepath).The fix
Commit 1 — stop the silent breakage.
docs.ErrNoSourceDirmakes a missing source directory reportable instead of reporting success.Service.Updatekeeps the no-op only when the project has no versions (then there really is nothing to move); otherwise it rolls the rename back and returnsErrStorageMissing, which the admin handler surfaces as a 409 explaining the rename was not applied. A store failure while counting versions is treated as "has versions", so an unreadable database refuses rather than commits.Commit 2 — repair the already-divorced projects. Version rows still carry the
StoragePathrecorded at upload time, and the pre-#122 code never rewrote it, so for a divorced project it points at where the files actually are.ReconcileStoragefollows that breadcrumb at startup and logs every repair.It only touches a project when all of these hold:
A breadcrumb pointing outside the storage root is ignored, so a corrupt
StoragePathcannot relocate anything from elsewhere on disk. The move reusesMoveProject, so the destination-exists guard applies here too. On a healthy install it is a no-op.Testing
npm test, and the release build all pass.Built-in docs updated: a "Slugs and storage paths" section in
explanation/architecture.mdcovering the refusal and the startup repair.Note for review
This fixes the failure mechanism and repairs the resulting state. What I could not verify from here is which specific prod projects are divorced — the startup log line (
repaired project storage directories) will report that on first boot after deploy. Worth watching the logs on the first restart.AI-assisted.