Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Catch invalid provider ids and rather log as info #49418

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading