Skip to main content

Bitbucket Webhooks Review

Bitbucket is a native Git tool in Atlassian’s Open DevOps solution.

When we look at webhook solutions, we’re generally looking for 7 things: signature verification, retries, manual retries, exponential backoff, visibility/logs, event types, and multiple endpoint support. For signature verification, our reference point is the Standard Webhooks specification, which defines the standard headers and signing scheme.

TL;DR:
✅ Signature Verification
⬜ Retries
⬜ Exponential Backoff
⬜ Manual Retries
✅ Visibility into Logs
✅ Event Types
✅ Multiple Endpoints Support

Signature Verification ✅​

Signature Verification is a critical security feature of webhooks. It lets users verify that a webhook was actually sent from the expected source.

Bitbucket Cloud now supports this. When you set a secret on a webhook, Bitbucket uses it to create an HMAC of the request body and sends it in the X-Hub-Signature header, formatted as method=signature (docs). The method is currently sha256, sent as a hex digest, and the docs include examples of validating it in several languages.

The secret is optional (the docs mark it as recommended) and the signature depends on it, so set one on every webhook.

Retries​

Webhook messages often fail. Without retries, users may miss many notifications which results in a bad user experience.

Bitbucket automatically resends a request up to two more times, and only when the response status is in the 500-599 range (troubleshooting docs). A request times out if Bitbucket gets no response within 10 seconds. Two extra attempts isn’t enough of a retry policy to earn a checkmark here: if your endpoint is down for more than a moment, you’ll miss events.

Looking to send webhooks at scale?

Schedule a Call

Exponential Backoff​

Exponential backoff is an algorithm that increases the delay between retries exponentially. This ensures that your system won’t get bottleneck from having to re-queue failed webhooks while also giving users time to fix broken endpoints before they burn through all their retry attempts.

There is no mention of the delay between attempts, and with only two retries there isn’t much room for a backoff schedule.

Manual Retries​

In the event that a user’s endpoint is failing, its nice to give the developer tasked with debugging the endpoint, the option to initiate a retry manually instead of having to wait for the next scheduled retry (this could be several hours of waiting if they’re close to the end of the retry schedule).

We could not find any mention of triggering retries manually.

Visibility into Logs ✅​

Giving users visibility into the delivery logs is critical for troubleshooting/debugging.

Bitbucket has a nice user interface for examining your webhook requests. History is off until you turn it on: open Repository settings > Webhooks > View requests and select Enable history, and Bitbucket starts recording every new request (docs).

Bitbucket webhook request log listing recent events such as pullrequest and repo, each with its time, HTTP status (200 or 501), and a View details link

They show you the event that triggered the webhook, the time it was triggered, its status, and a link to view more details, including the request and response for each attempt. The attempt number is also sent in the X-Attempt-Number header of each request.

Event Types ✅​

Event types are identifiers denoting the type of message being sent and are the primary way for webhook consumers to configure what events they are interested in receiving.

There is an extensive list of available event types with code samples here: Bitbucket Event Payloads.

Multiple Endpoint Support ✅​

Many webhook solutions only allow one endpoint URL to be specified where all messages will be received. By enabling your users to create multiple endpoints, they’ll be able to choose which endpoints receive which messages. Multiple endpoint support and event types go hand in hand.

Bitbucket allows creating multiple endpoints through the webhooks section in a repository’s settings. There is a limit of 50 webhooks per repository.

Summary​

Bitbucket has closed the biggest gap from our first review: webhooks can now be signed, as long as you set a secret. We also like that they have a page dedicated to troubleshooting. We’d still like to see more retries offered with exponential backoff, to give developers time to resolve a failing endpoint before events are lost, and a way to resend a failed request manually.

If you’re looking to implement world class webhooks, consider trying Svix, the enterprise ready webhooks service. Svix makes it super easy to build a secure, reliable, and scalable webhook solution through an API.