diff --git a/backend/app/api/v1/routes_clients.py b/backend/app/api/v1/routes_clients.py index 225faca..fd28c3b 100644 --- a/backend/app/api/v1/routes_clients.py +++ b/backend/app/api/v1/routes_clients.py @@ -216,7 +216,7 @@ async def deactivate_client( resource_type="client", resource_id=client_id, resource_name=doc["name"], - details={}, + details={"was_active": doc.get("is_active", True)}, ) diff --git a/backend/app/services/audit_logger.py b/backend/app/services/audit_logger.py index 1ca34c6..fee7071 100644 --- a/backend/app/services/audit_logger.py +++ b/backend/app/services/audit_logger.py @@ -94,11 +94,15 @@ class AuditLogger: api_version="v1" ) - # Save to database + # Save to database — non-raising so audit failure never aborts the primary operation collection = await self._get_collection() - result = await collection.insert_one(audit_log.dict(by_alias=True)) - - return str(result.inserted_id) + try: + result = await collection.insert_one(audit_log.dict(by_alias=True)) + return str(result.inserted_id) + except Exception as exc: # noqa: BLE001 + import logging + logging.getLogger(__name__).error("audit log insert failed: %s", exc) + return "" @trace_async_operation("audit_logger.query_logs") async def query_logs(self, query: AuditLogQuery) -> AuditLogResponse: