Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Webhook] SerializerInterface is not actually needed #57567

Closed
@jenky

Description

@jenky

Symfony version(s) affected

7.x

Description

You cannot use the "webhook transport" service since the Serializer component is not installed. Try running "composer require symfony/serializer-pack". 

A quick search shows that this line is the only place where the serializer is used in the webhook component.

https://github.com/symfony/webhook/blob/67762b59de4b9e3c6918c44a345f59030923b82d/Server/JsonBodyConfigurator.php#L24

To be fair I don't think this is a bug, however serializer is not really needed to encode the event payload since it's always array, json_encode is fine.

How to reproduce

Create a new SendWebhookMessage then dispatch it without installing the serializer

Possible Solution

Remove SerializerInterface and replace

$body = $this->serializer->serialize($event->getPayload(), 'json');

with

$body = \json_encode($event->getPayload());

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions