From 36e2e889ab89d1dc644f3e69ddce9bf9f938a827 Mon Sep 17 00:00:00 2001 From: Julius Knorr Date: Thu, 21 Nov 2024 09:18:34 +0100 Subject: [PATCH] fix: Catch invalid provider ids and rather log as info Signed-off-by: Julius Knorr --- lib/private/Teams/TeamManager.php | 9 ++++++++- lib/public/Teams/ITeamManager.php | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/private/Teams/TeamManager.php b/lib/private/Teams/TeamManager.php index d75b0209c7187..d3ef286ae1da3 100644 --- a/lib/private/Teams/TeamManager.php +++ b/lib/private/Teams/TeamManager.php @@ -18,6 +18,7 @@ use OCP\Teams\Team; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; +use Psr\Log\LoggerInterface; class TeamManager implements ITeamManager { @@ -28,6 +29,7 @@ public function __construct( private Coordinator $bootContext, private IURLGenerator $urlGenerator, private ?CirclesManager $circlesManager, + private LoggerInterface $logger, ) { } @@ -88,7 +90,12 @@ public function getTeamsForResource(string $providerId, string $resourceId, stri return []; } - $provider = $this->getProvider($providerId); + try { + $provider = $this->getProvider($providerId); + } catch (\RuntimeException $e) { + $this->logger->info($e->getMessage(), ['exception' => $e]); + return []; + } return array_values(array_filter(array_map(function ($teamId) use ($userId) { $team = $this->getTeam($teamId, $userId); if ($team === null) { diff --git a/lib/public/Teams/ITeamManager.php b/lib/public/Teams/ITeamManager.php index 144a141f93eb7..844e4d00d34ed 100644 --- a/lib/public/Teams/ITeamManager.php +++ b/lib/public/Teams/ITeamManager.php @@ -6,6 +6,8 @@ namespace OCP\Teams; +use RuntimeException; + /** * @since 29.0.0 */ @@ -21,6 +23,7 @@ public function getProviders(): array; /** * Get a specific team resource provider by its id * + * @throws RuntimeException * @since 29.0.0 */ public function getProvider(string $providerId): ITeamResourceProvider;