feat(v2): delete artifacts (files + external links) from inspector#274
Open
feat(v2): delete artifacts (files + external links) from inspector#274
Conversation
Pod owner OR original creator can now delete an artifact from the inspector detail view. Backend enforces independently; frontend gates the button. Backend: - DELETE /api/pods/:podId/files/:fileId — owner | uploader. Deletes bytes from the configured ObjectStore driver and the File row. Driver delete failures are logged but don't block the metadata delete; orphaned bytes can be GC'd later (ADR-002 Phase 4 sweep). Validates fileId shape against the ObjectId regex before any DB call (ReDoS guard). - DELETE /api/pods/external-link/:id relaxed from owner-only to owner | createdBy. Pod members at large still can't nuke shared links — keeps a malicious pod-mate from clearing artifacts. Frontend: - V2PodInspector renderArtifactDetail gains a Delete button next to Open when the viewer is permitted (pod owner OR creator). - ArtifactItems carry sourceKind / sourceId / createdById so the detail view knows which DELETE endpoint to hit and whether the current viewer can. - Confirm dialog (window.confirm) before delete; on success we remove the item from local state and pop back to the overview. - Announcements stay non-deletable from this surface — those live in a separate admin flow. Tests: 35/35 passing. - pods.external-links.test.js: 28 cases (was 27). New "allows the link creator to delete (even if not pod owner)" + updated 403 case to assert "neither owner nor creator". - pods.files-delete.test.js: 7 new cases. Owner can delete, uploader can delete, neither 403, invalid fileId 400, missing file 404, wrong-pod 404, ObjectStore failure doesn't block metadata delete. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| if (!fileDoc) return res.status(404).json({ message: 'File not found' }); | ||
| if (fileDoc.podId?.toString() !== podId) return res.status(404).json({ message: 'File not in this pod' }); | ||
| const pod = await Pod.findById(podId) as { createdBy?: { toString: () => string } } | null; | ||
| if (!pod) return res.status(404).json({ message: 'Pod not found' }); |
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.
Third of three "artifact polish" PRs. Will not auto-merge.
What this changes
Pod owner OR original creator can now delete an artifact from the inspector detail view.
Backend:
Frontend:
What's deliberately not deletable
Announcements aren't deletable from the inspector. Those live in a separate admin flow (and the legacy `DELETE /api/pods/announcement/:id` route). If we want to surface a delete here later we add a 4th `sourceKind` and a permission check.
Tests
35/35 passing.
Test plan
🤖 Generated with Claude Code