We have a api endpoint like
#[MapRequestPayload(acceptFormat: 'json', resolver: CustomValueResolver::class)] ExampleDTO $data
And resolver is supposed to send 422 response with violations
final class CustomValueResolver implements ValueResolverInterface, EventSubscriberInterface
{
private DefaultRequestPayloadValueResolver $defaultResolver;
public function __construct(
SerializerInterface&DenormalizerInterface $serializer,
?ValidatorInterface $validator = null,
?TranslatorInterface $translator = null,
) {
$this->defaultResolver = new DefaultRequestPayloadValueResolver($serializer, $validator, $translator);
}
public static function getSubscribedEvents(): array
{
return [
KernelEvents::CONTROLLER_ARGUMENTS => 'onKernelControllerArguments',
];
}
public function resolve(Request $request, ArgumentMetadata $argument): iterable
{
return $this->defaultResolver->resolve($request, $argument);
}
public function onKernelControllerArguments(ControllerArgumentsEvent $event): void
{
try {
$this->defaultResolver->onKernelControllerArguments($event);
} catch (HttpException $e) {
$previous = $e->getPrevious();
if ($previous instanceof ValidationFailedException) {
throw new ValidationException($previous->getViolations());
}
throw $e;
}
}
}
But after updating to api-platform 3.2 we are getting 500 errors with the trace of the exception
Anything that might go wrong?