Skip to content

How to handle invalid webhook payloads? #967

@leplatrem

Description

@leplatrem

JBI could fail at parsing Webhook incoming request with:

Currently, JBI logs the error and returns HTTP 422.

We may want to leverage the queue to return HTTP 200 instead and store the payload.

option 0: status quo

Do not change current behaviour

option 1: refactor queue code to allow arbitrary payloads

Current code uses track_failed(payload: bugzilla.WebhookRequest, exc: Exception)

In order to be able to store the invalid incoming payload in the queue, we would have to modify the queue methods and models to allow arbitrary payloads.

This would prevent us from accessing payload attributes like this:

return f"{self.payload.event.time}-{self.payload.bug.id}-{self.payload.event.action}-{"error" if self.error else "postponed"}"

Turning the arbitrary payload into WebhookRequest would happen explicitly in the retry_failed() code before calling execute_action()

option 2: add new queue method

Instead of changing the models we could add backend and queue methods:

  • track_invalid(payload: Any, exc: Exception)
  • backend.put_raw(item_raw: Any, exc: PythonException)

This would store the content in the queue, assuming that the retry job won't be able to process the content until the code is changed and redeployed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions