Skip to content

webhook_listeners only supports events with less than 4000 characters payload due to background jobs limitation and may break a request #58912

@ShGKme

Description

@ShGKme

webhook_listeners creates a background job with a payload from the webhook event.
If the payload is bigger then:

  1. Webhook is not created
  2. A request creating the event fails

background job arguments cannot exceed 4000 characters

class WebhooksEventListener implements IEventListener {
public function __construct(
private WebhookListenerMapper $mapper,
private IJobList $jobList,
private LoggerInterface $logger,
private IUserSession $userSession,
) {
}
public function handle(Event $event): void {
$user = $this->userSession->getUser();
$webhookListeners = $this->mapper->getByEvent($event::class, $user?->getUID());
foreach ($webhookListeners as $webhookListener) {
// TODO add group membership to be able to filter on it
$data = [
'event' => $this->serializeEvent($event),
/* Do not remove 'user' from here, see BackgroundJobs/WebhookCall.php */
'user' => (is_null($user) ? null : JsonSerializer::serializeUser($user)),
'time' => time(),
];
if ($this->filterMatch($webhookListener->getEventFilter(), $data)) {
$this->jobList->add(
WebhookCall::class,
[
$data,
$webhookListener->getId(),
/* Random string to avoid collision with another job with the same parameters */
bin2hex(random_bytes(5)),
]
);
}
}
}

Intermediate solution: at least wrap it into a try catch block and log the error, so failed background job creation doesn't fail the request.

A proper solution is to store the data somewhere else or add support for large data in background jobs.

cc @come-nc @artonge

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Confirmed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions