M1-audit: org approve can strand a request Approved with no tenant — retry impossible #93
Labels
No labels
epic
phase-0
phase-1
phase-2
phase-3
phase-4
phase-5
phase-6
phase-7
phase-8
phase-9
priority/P0
priority/P1
priority/P2
type/backend
type/client
type/docs
type/ops
type/security
type/spike
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/failsulit#93
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
ApproveRequest.cs commits the Status flip FIRST (ExecuteUpdate, 33-38), then slug generation (409 on exhaustion, 49-50) and SaveChanges (409 'retry', 92-95) — but a retry hits 'already decided' (39-40). SaveChanges-failure variant leaves founder TenantId pointing at a tenant with no UserTenant Owner row. Audit-Log throw after commit 500s an operation that actually committed.
Fix: one transaction around flip+tenant+founder+membership (slug loop inside; unique failure = rollback → clean 409). Test: slug-collision + injected save failure.
Part of M1 closure audit #84.
Fixed in PR #116 (squash-merged as
b0945c9). ApproveRequest wraps flip + slug + tenant + founder + membership + audit in ONE transaction — slug exhaustion or a mid-tx save failure rolls the Pending→Approved flip back; the request stays Pending and 'please retry' is actually possible. Audit moved inside the tx (no more 500-after-commit); notifications/email remain post-commit best-effort. Tests: slug-exhaustion (101 occupied slugs → 409, still Pending, founder untouched) + injected mid-transaction failure (409 → retry succeeds with exactly one Owner seat).