fix(audit): deactivate_client details + non-raising audit insert in service
This commit is contained in:
parent
bd1dd69467
commit
42a0c8acb1
2 changed files with 9 additions and 5 deletions
|
|
@ -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)},
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue