Add the delete place endpoint for Owner and Editor #52
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/delete-place-endpoint"
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?
Vikunja task 70.
DELETE /api/places/{id}, 204 on success. UsesGroupMayDeletePlacesPolicy(ADR-0041) viaRequireGroupCapabilityForPlace(ADR-0045) — the first endpoint to use that policy, proving ADR-0039's decision that an Editor may delete places. Hard delete, no cascade: nothing else references a place's id (ADR-0005).Already-gone decision:
RequireGroupCapabilityForPlaceloads the place before the handler runs and answers 404 for a nonexistent id, exactly asGET /api/places/{id}already does — so a repeat delete answers 404, not an idempotent 204. Chosen for consistency with every other route under this filter rather than carving out a special case for one verb;PlaceEndpoints.DeletePlace's own remarks note it. IfDeleteAsyncever finds no row despite the filter having just loaded one (a race outside this app's hobby-scale posture, ADR-0007), that's treated as a defect, matchingGroupEndpoints.DeleteGroup's existing pattern.Sibling-places boundary is tested explicitly, per PR #51's finding: a group with several places, one deleted, the group and the other places asserted intact by field.
Verdict: mergeable
Verified directly, not just read: widening
DeletePlaceByIdtoDELETE FROM places WHERE group_id = (SELECT group_id FROM places WHERE id = @Id)reddens both the sibling-boundary tests (API and repository level); reverted. Mutating the route toGroupCapability.Ownerreddens the Editor case, confirming Editor genuinely succeeds under the real policy; reverted.One gap worth noting, not blocking: mutating the route to
GroupCapability.MayEditPlacesinstead ofMayDeletePlacesleaves all 8DeletePlaceEndpointTestsgreen, becauseGroupPermissions.CanEditPlacesandCanDeletePlacesare identical thresholds today (by ADR-0041's own design — kept as separate policies only because they may diverge). Nothing here proves the endpoint specifically declaresMayDeletePlacesrather than the edit policy other than reading the code. A cheap fix: assert onGroupCapabilityMetadatafor the delete route's specificGroupCapabilityvalue, the wayGroupScopedEndpointAuthorisationTestsalready reads that metadata for presence — doesn't need a database.On the already-deleted question: confirmed 404 here is actually consistent with
DELETE /api/groups/{groupId}in practice, not just by the stated rationale — group deletion cascadesgroup_membershipstoo (ON DELETE CASCADE), so a repeat group delete also lands on "no membership row" → 404 via the sameHidesGroupExistencepath. The two endpoints agree.No second load, hard delete with nothing to cascade, and the merge with main (PR #50/#51) resolves cleanly — full solution build and test suite green post-merge,
PlaceResponse.Versiondoesn't interact with this endpoint since it returns 204 with no body.Addressed: added
DeletePlaceEndpointMetadataTestsasserting the DELETE route'sGroupCapabilityMetadatanamesMayDeletePlacesspecifically — proved red by temporarily wiring the route toMayEditPlaces, then restored. Also mergedmain(PR #50, #51);PlaceResponse.Versiondoesn't affect this endpoint (204, no body). CI sequence includingdotnet format --verify-no-changesclean at head6b81fd8.Verdict: mergeable
Verified
DeletePlaceEndpointMetadataTestsdirectly: swapping the route toGroupCapability.MayEditPlacesreddens it with the expected failure (GroupCapability.MayEditPlacesvs expectedMayDeletePlaces), reverting turns it green. That closes the gap from the previous review.Checked the hand-resolved
mainmerge (d51809a) for drops: bothPUTandDELETEroutes present and correctly mapped inPlaceEndpoints.cs, all five handlers (PostCreatePlace,GetPlaces,GetPlaceById,PutUpdatePlace,DeletePlace) intact;PlaceRepositoryTests.cshas all three delete tests and all four update tests, including PR #50's concurrent-writers race test. No leftover conflict markers anywhere. Full solution build and test run post-merge: 386/386 API tests, 196/196 infrastructure tests, all green.ADR index (
docs/adr/README.md) is in numeric order 0001–0048, no gaps.