B-1 Audit sink poisons requests: Guid.Empty actor FK + shared DbContext (root cause of flaky tests) #32
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#32
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?
Introduced by commit
997f657(Mar 24). SsdidAuditSink.cs:36 writes audit rows with ActorId=Guid.Empty — FK violation vs users.id — fire-and-forget into the request-scoped DbContext (Program.cs:99), poisoning handlers' awaited SaveChanges (DbContext is not thread-safe). Result: 371 failed audit_log inserts + 51 'concurrent insert expected but user not found' 500s per test run = the 26–29 flaky tests (task #27); production silently loses ALL SDK audit rows; wallet register/login 500s intermittently.Fixes:
dotnet test(add UseMicrosoftTestingPlatformRunner or Test.Sdk + xunit.runner.visualstudio)Unblocks #27 (flaky triage → verify 3 consecutive zero-failure runs). Full findings + evidence: docs/redesign/2026-11-onboarding-passkey/08-code-baseline-review.md
Fixed in commit
be3d502(TDD: AuditSinkTests red at predicted lines → green).AuditLogEntry.ActorId→Guid?, FKSetNull, migrationAuditActorNullableIServiceScopeFactoryscope, try/catch + warning log — audit failures can never surface into a user responseRegisterVerifycatch narrowed to unique-constraint violationsCancellationToken.NoneVerification: 3 consecutive zero-failure runs — 680/680 ×3 (Release), first fully-green suite since March. Unblocks #27 (coverage gate; hook failure-tolerance now retirable).