fix(gitea) : propagate API errors instead of silently returning empty results
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@ use App\Entity\Task;
|
||||
use App\Exception\GiteaApiException;
|
||||
use App\Service\GiteaApiService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
final readonly class GiteaBranchProvider implements ProviderInterface
|
||||
{
|
||||
@@ -40,8 +41,8 @@ final readonly class GiteaBranchProvider implements ProviderInterface
|
||||
|
||||
try {
|
||||
$branches = $this->giteaApiService->listBranches($project, $taskCode);
|
||||
} catch (GiteaApiException) {
|
||||
return [];
|
||||
} catch (GiteaApiException $e) {
|
||||
throw new BadRequestHttpException($e->getMessage(), $e);
|
||||
}
|
||||
|
||||
$result = [];
|
||||
@@ -58,6 +59,7 @@ final readonly class GiteaBranchProvider implements ProviderInterface
|
||||
'date' => $c['commit']['author']['date'] ?? $c['created'] ?? '',
|
||||
], $commits);
|
||||
} catch (GiteaApiException) {
|
||||
// Commits fetch failure should not block branch listing
|
||||
$dto->commits = [];
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Entity\Task;
|
||||
use App\Exception\GiteaApiException;
|
||||
use App\Service\GiteaApiService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
final readonly class GiteaPullRequestProvider implements ProviderInterface
|
||||
{
|
||||
@@ -35,8 +36,8 @@ final readonly class GiteaPullRequestProvider implements ProviderInterface
|
||||
|
||||
try {
|
||||
$prs = $this->giteaApiService->listPullRequests($project, $taskCode);
|
||||
} catch (GiteaApiException) {
|
||||
return [];
|
||||
} catch (GiteaApiException $e) {
|
||||
throw new BadRequestHttpException($e->getMessage(), $e);
|
||||
}
|
||||
|
||||
return array_map(static function (array $pr): GiteaPullRequest {
|
||||
|
||||
@@ -9,6 +9,7 @@ use ApiPlatform\State\ProviderInterface;
|
||||
use App\ApiResource\GiteaRepository;
|
||||
use App\Exception\GiteaApiException;
|
||||
use App\Service\GiteaApiService;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
final readonly class GiteaRepositoryProvider implements ProviderInterface
|
||||
{
|
||||
@@ -20,8 +21,8 @@ final readonly class GiteaRepositoryProvider implements ProviderInterface
|
||||
{
|
||||
try {
|
||||
$repos = $this->giteaApiService->listRepositories();
|
||||
} catch (GiteaApiException) {
|
||||
return [];
|
||||
} catch (GiteaApiException $e) {
|
||||
throw new BadRequestHttpException($e->getMessage(), $e);
|
||||
}
|
||||
|
||||
return array_map(static function (array $repo): GiteaRepository {
|
||||
|
||||
Reference in New Issue
Block a user