Summary
On the SQL (better-sqlite3) driver, every record insert/update triggers an audit write that fails, because the audit writer's INSERT INTO sys_audit_log includes an organization_id column the table doesn't have. The error is caught (Audit write failed) so the business mutation still succeeds — but no audit row is ever persisted.
Version
@objectstack/* 7.6.0, driver-sql (better-sqlite3), single-tenant.
Error (verbatim, on every write)
ERROR Insert operation failed {"object":"sys_audit_log","error":{"message":
"insert into `sys_audit_log` (`action`, `created_at`, `created_by`, `id`, `new_value`,
`object_name`, `old_value`, `organization_id`, `record_id`, `tenant_id`, `updated_at`,
`updated_by`, `user_id`) values (...) returning *
- table sys_audit_log has no column named organization_id"}}
at SqlDriver.create (@objectstack/driver-sql/dist/index.mjs:322)
at _ObjectQL.triggerHooks (@objectstack/objectql/dist/index.mjs:5935)
WARN Audit write failed {"object":"crm_lead","action":"create", ...}
Note the INSERT column list emits both organization_id and tenant_id; the created sys_audit_log table is missing organization_id.
Repro
- Any stack on the sqlite driver with the audit service active (default slate).
- Create or update any record via REST / ObjectQL.
- Server log shows
Insert operation failed {object: sys_audit_log …} followed by Audit write failed.
Impact
- Audit logging is silently non-functional on this driver — compliance / audit-trail gap that looks fine from the app's perspective (writes succeed).
- Every mutation pays a failed SQL round-trip + caught exception (noise + minor perf).
Likely cause
The sys_audit_log system-object definition / migration in the audit plugin is out of sync with the columns the audit writer INSERTs (organization_id, and possibly tenant_id). Either the table needs those columns added to its schema/migration, or the writer should stop emitting columns the object doesn't declare.
Found while upgrading objectstack-ai/hotcrm to 7.6 (objectstack-ai/hotcrm#365). The audit failure is non-fatal but reproduces on 100% of writes.
Summary
On the SQL (better-sqlite3) driver, every record insert/update triggers an audit write that fails, because the audit writer's
INSERT INTO sys_audit_logincludes anorganization_idcolumn the table doesn't have. The error is caught (Audit write failed) so the business mutation still succeeds — but no audit row is ever persisted.Version
@objectstack/*7.6.0,driver-sql(better-sqlite3), single-tenant.Error (verbatim, on every write)
Note the INSERT column list emits both
organization_idandtenant_id; the createdsys_audit_logtable is missingorganization_id.Repro
Insert operation failed {object: sys_audit_log …}followed byAudit write failed.Impact
Likely cause
The
sys_audit_logsystem-object definition / migration in the audit plugin is out of sync with the columns the audit writer INSERTs (organization_id, and possiblytenant_id). Either the table needs those columns added to its schema/migration, or the writer should stop emitting columns the object doesn't declare.Found while upgrading objectstack-ai/hotcrm to 7.6 (objectstack-ai/hotcrm#365). The audit failure is non-fatal but reproduces on 100% of writes.