fix(audit): store plugin entries with no acting user as a null user_id (#1556)

Plugin audit entries written outside a request used the literal "system"
as user_id. That column references users.id, so the insert was refused
(Postgres logs it as an FK violation) and the entry was silently dropped.
Write null instead and keep "system" / plugin:<id> in username.
This commit is contained in:
ZacharyZcR authored and GitHub committed 2026-10-04 18:40:13 +08:00
1 parent 4c9e12f3b7
commit abbfca2e94
7 files changed
+40 -9

No files matched your search

+2 -1
View File
@@ -73,7 +73,8 @@ describe("ctx.audit.record", () => {
const ctx = contextFor("audit-fixture");
await ctx.audit.record({ action: "cleanup", success: false });
expect(auditEntries[0]).toMatchObject({
userId: "system",
userId: null,
username: "system",
resourceType: "plugin",
resourceId: "audit-fixture",
resourceName: "Audit Fixture",