fix: Orphan sweep API deletes product source files#25
Open
jonathanchang31 wants to merge 1 commit into
Open
Conversation
Author
|
@aglover1221 Could you plz review my PR? |
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.
Summary
POST /api/pipeline/orphanscould delete product source files whensources.yamlwas missing. The orphan sweep treated a missing manifest as an empty allowlist, classified every top-level file insource/as orphaned, and deleted them by default.This change makes missing manifests non-destructive, makes POST dry-run by default, and requires explicit confirmation before any orphan deletion can occur.
Related Issue
Fixed: #24
Change Type
What Changed
listOrphans()now reports:manifestPathmanifestMissingIf
sources.yamlis missing:GET /api/pipeline/orphansreturnsmanifestMissing: truePOST /api/pipeline/orphansis now dry-run by default.Real deletion now requires:
{ "productSlug": "r770", "dryRun": false, "confirmDelete": true }Even with confirmation, deletion is blocked with
409 Conflictifsources.yamlis missing.Added regression tests covering:
sources.yamldoes not classify files as orphanssources.yamlrefuses deletionReal Behavior Proof
Before Fix
With
sources.yamlmissing:A normal POST deleted the source file:
Result:
After Fix
With
sources.yamlstill missing:GET now reports the missing manifest and no deletable orphans:
{ "productSlug": "r770", "manifestMissing": true, "manifestFilenames": [], "orphans": [] }Default POST is safe and does not delete:
Even explicit confirmed delete is refused when manifest is missing:
Validation Performed
Result:
npm testResult:
Result:
Result:
Runtime route checks:
Security / Business Impact
This prevents accidental or unauthenticated deletion of product source files.
Risk before fix:
sources.yamlcaused all top-level files insource/to be treated as orphans.Risk after fix:
Checklist
sources.yamlis missing