You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(user_status): add debug logging to silent failure paths
Multiple code paths in StatusService silently swallowed failures,
making it impossible to debug status reliability issues. Add debug
logging for: backup creation conflicts, aborted automated status
changes, failed revert operations, and concurrent insert conflicts.
AI-Assisted-By: Claude Opus 4.6
Signed-off-by: Anna Larch <anna@nextcloud.com>
Copy file name to clipboardExpand all lines: apps/user_status/lib/Service/StatusService.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -284,6 +284,7 @@ public function setUserStatus(string $userId,
284
284
285
285
if ($createBackup) {
286
286
if ($this->backupCurrentStatus($userId) === false) {
287
+
$this->logger->debug('Automated status change aborted for user ' . $userId . ': backup already exists (another automated status is active)', ['app' => 'user_status']);
287
288
returnnull; // Already a status set automatically => abort.
288
289
}
289
290
@@ -516,6 +517,7 @@ public function backupCurrentStatus(string $userId): bool {
516
517
returntrue;
517
518
} catch (Exception$ex) {
518
519
if ($ex->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
520
+
$this->logger->debug('Backup status already exists for user ' . $userId . ', skipping backup creation', ['app' => 'user_status']);
519
521
returnfalse;
520
522
}
521
523
throw$ex;
@@ -533,7 +535,7 @@ public function revertUserStatus(string $userId, string $messageId, bool $revert
// Another status is set automatically or no status, do nothing
538
+
$this->logger->debug('Status revert skipped for user ' . $userId . ': current status does not match messageId "' . $messageId . '" (user may have changed status manually)', ['app' => 'user_status']);
537
539
returnnull;
538
540
}
539
541
@@ -589,10 +591,10 @@ protected function insertWithoutThrowingUniqueConstrain(UserStatus $userStatus):
589
591
try {
590
592
return$this->mapper->insert($userStatus);
591
593
} catch (Exception$e) {
592
-
// Ignore if a parallel request already set the status
593
594
if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
594
595
throw$e;
595
596
}
597
+
$this->logger->debug('Concurrent insert conflict for user ' . $userStatus->getUserId() . ': status was already set by a parallel request', ['app' => 'user_status']);
0 commit comments