fix: correct HTTP codes for Bad Request

This commit is contained in:
Maël Gangloff 2025-10-07 16:33:27 +02:00
parent ea1df9d97a
commit f2c52eded1
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
3 changed files with 12 additions and 4 deletions

View File

@ -38,6 +38,6 @@ api_platform:
ApiPlatform\Validator\Exception\ValidationException: !php/const Symfony\Component\HttpFoundation\Response::HTTP_UNPROCESSABLE_ENTITY
App\Exception\DomainNotFoundException: 404
App\Exception\MalformedDomainException: 403
App\Exception\TldNotSupportedException: 403
App\Exception\UnknownRdapServerException: 403
App\Exception\MalformedDomainException: 400
App\Exception\TldNotSupportedException: 400
App\Exception\UnknownRdapServerException: 400

View File

@ -41,7 +41,8 @@ final readonly class UpdateDomainsFromWatchlistHandler
private WatchListRepository $watchListRepository,
private LoggerInterface $logger,
#[Autowire(service: 'service_container')]
private ContainerInterface $locator, private DomainRepository $domainRepository,
private ContainerInterface $locator,
private DomainRepository $domainRepository,
) {
$this->sender = new Address($mailerSenderEmail, $mailerSenderName);
}

View File

@ -224,6 +224,9 @@ class RDAPService
$tldEntity = $this->tldRepository->findOneBy(['tld' => $tld]);
if (null === $tldEntity) {
$this->logger->warning('Domain name cannot be updated because the TLD is not supported', [
'ldhName' => $domain,
]);
throw TldNotSupportedException::fromTld($domain);
}
@ -244,6 +247,10 @@ class RDAPService
$rdapServer = $this->rdapServerRepository->findOneBy(['tld' => $tldString], ['updatedAt' => 'DESC']);
if (null === $rdapServer) {
$this->logger->warning('Unable to determine which RDAP server to contact', [
'tld' => $tldString,
]);
throw UnknownRdapServerException::fromTld($tldString);
}