Skip to content

Commit 613e00f

Browse files
fixup! feat(user-stats): wire UserStatsJob to send stats to PSS via API client
Pass the Throwable object to the logger instead of its message string. Nextcloud's logger treats 'exception' => $throwable specially and serializes the full stack trace; passing a plain string silently drops the trace, making transient but unexpected errors hard to diagnose. Update the corresponding test assertion accordingly. Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 649826f commit 613e00f

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎lib/BackgroundJob/UserStatsJob.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected function run(mixed $argument): void {
7474
$api->updateStats($brand, $extRef, $request);
7575
} catch (\Throwable $e) {
7676
$this->logger->error('UserStatsJob: failed to push stats to PSS', [
77-
'exception' => $e->getMessage(),
77+
'exception' => $e,
7878
]);
7979
}
8080
}

‎tests/unit/BackgroundJob/UserStatsJobTest.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ public function testRunLogsErrorWhenApiThrows(): void {
9090
$this->logger->expects($this->once())
9191
->method('error')
9292
->with('UserStatsJob: failed to push stats to PSS', $this->callback(function (array $ctx): bool {
93-
return str_contains($ctx['exception'], 'connection refused');
93+
return $ctx['exception'] instanceof \Exception
94+
&& str_contains($ctx['exception']->getMessage(), 'connection refused');
9495
}));
9596

9697
$this->invokePrivate($this->job, 'run', [null]);

0 commit comments

Comments
 (0)