Skip to content

Commit

Permalink
fix: Catch invalid provider ids and rather log as info
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Knorr <[email protected]>
  • Loading branch information
juliusknorr committed Nov 21, 2024
1 parent 37936bc commit 36e2e88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/private/Teams/TeamManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use OCP\Teams\Team;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;

class TeamManager implements ITeamManager {

Expand All @@ -28,6 +29,7 @@ public function __construct(
private Coordinator $bootContext,
private IURLGenerator $urlGenerator,
private ?CirclesManager $circlesManager,
private LoggerInterface $logger,
) {
}

Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions lib/public/Teams/ITeamManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace OCP\Teams;

use RuntimeException;

/**
* @since 29.0.0
*/
Expand All @@ -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;
Expand Down

0 comments on commit 36e2e88

Please sign in to comment.