Skip to content

Commit bd84968

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(bitbucket): harden webhook trigger delivery
1 parent 4d3d5a8 commit bd84968

7 files changed

Lines changed: 857 additions & 203 deletions

File tree

apps/docs/content/docs/en/integrations/bitbucket.mdx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ Trigger workflow when a build status is created for a Bitbucket commit
15751575
| `attemptNumber` | number | Bitbucket delivery attempt number |
15761576
| `actor` | json | User or app that caused the event |
15771577
| `repository` | json | Repository where the event occurred |
1578-
| `payload` | json | Full raw Bitbucket webhook payload |
1578+
| `payload` | json | Full parsed Bitbucket webhook payload |
15791579
| `commitStatus` | json | Bitbucket commit status object |
15801580
| `commitHash` | string | Hash of the commit with this status |
15811581
| `statusKey` | string | Key identifying the build status |
@@ -1610,7 +1610,7 @@ Trigger workflow when a build status is updated for a Bitbucket commit
16101610
| `attemptNumber` | number | Bitbucket delivery attempt number |
16111611
| `actor` | json | User or app that caused the event |
16121612
| `repository` | json | Repository where the event occurred |
1613-
| `payload` | json | Full raw Bitbucket webhook payload |
1613+
| `payload` | json | Full parsed Bitbucket webhook payload |
16141614
| `commitStatus` | json | Bitbucket commit status object |
16151615
| `commitHash` | string | Hash of the commit with this status |
16161616
| `statusKey` | string | Key identifying the build status |
@@ -1645,7 +1645,7 @@ Trigger workflow when a comment is created on a Bitbucket commit
16451645
| `attemptNumber` | number | Bitbucket delivery attempt number |
16461646
| `actor` | json | User or app that caused the event |
16471647
| `repository` | json | Repository where the event occurred |
1648-
| `payload` | json | Full raw Bitbucket webhook payload |
1648+
| `payload` | json | Full parsed Bitbucket webhook payload |
16491649
| `comment` | json | Bitbucket comment object |
16501650
| `commentId` | number | Repository-scoped comment ID |
16511651
| `commentContent` | string | Raw text content of the comment |
@@ -1678,7 +1678,7 @@ Trigger workflow when approval is removed from a Bitbucket pull request
16781678
| `attemptNumber` | number | Bitbucket delivery attempt number |
16791679
| `actor` | json | User or app that caused the event |
16801680
| `repository` | json | Repository where the event occurred |
1681-
| `payload` | json | Full raw Bitbucket webhook payload |
1681+
| `payload` | json | Full parsed Bitbucket webhook payload |
16821682
| `pullRequest` | json | Bitbucket pull request object |
16831683
| `pullRequestId` | number | Repository-scoped pull request ID |
16841684
| `pullRequestTitle` | string | Pull request title |
@@ -1714,7 +1714,7 @@ Trigger workflow when a Bitbucket pull request is approved
17141714
| `attemptNumber` | number | Bitbucket delivery attempt number |
17151715
| `actor` | json | User or app that caused the event |
17161716
| `repository` | json | Repository where the event occurred |
1717-
| `payload` | json | Full raw Bitbucket webhook payload |
1717+
| `payload` | json | Full parsed Bitbucket webhook payload |
17181718
| `pullRequest` | json | Bitbucket pull request object |
17191719
| `pullRequestId` | number | Repository-scoped pull request ID |
17201720
| `pullRequestTitle` | string | Pull request title |
@@ -1750,7 +1750,7 @@ Trigger workflow when a changes request is removed from a Bitbucket pull request
17501750
| `attemptNumber` | number | Bitbucket delivery attempt number |
17511751
| `actor` | json | User or app that caused the event |
17521752
| `repository` | json | Repository where the event occurred |
1753-
| `payload` | json | Full raw Bitbucket webhook payload |
1753+
| `payload` | json | Full parsed Bitbucket webhook payload |
17541754
| `pullRequest` | json | Bitbucket pull request object |
17551755
| `pullRequestId` | number | Repository-scoped pull request ID |
17561756
| `pullRequestTitle` | string | Pull request title |
@@ -1786,7 +1786,7 @@ Trigger workflow when changes are requested on a Bitbucket pull request
17861786
| `attemptNumber` | number | Bitbucket delivery attempt number |
17871787
| `actor` | json | User or app that caused the event |
17881788
| `repository` | json | Repository where the event occurred |
1789-
| `payload` | json | Full raw Bitbucket webhook payload |
1789+
| `payload` | json | Full parsed Bitbucket webhook payload |
17901790
| `pullRequest` | json | Bitbucket pull request object |
17911791
| `pullRequestId` | number | Repository-scoped pull request ID |
17921792
| `pullRequestTitle` | string | Pull request title |
@@ -1822,7 +1822,7 @@ Trigger workflow when a comment is created on a Bitbucket pull request
18221822
| `attemptNumber` | number | Bitbucket delivery attempt number |
18231823
| `actor` | json | User or app that caused the event |
18241824
| `repository` | json | Repository where the event occurred |
1825-
| `payload` | json | Full raw Bitbucket webhook payload |
1825+
| `payload` | json | Full parsed Bitbucket webhook payload |
18261826
| `pullRequest` | json | Bitbucket pull request object |
18271827
| `pullRequestId` | number | Repository-scoped pull request ID |
18281828
| `pullRequestTitle` | string | Pull request title |
@@ -1860,7 +1860,7 @@ Trigger workflow when a comment is deleted from a Bitbucket pull request
18601860
| `attemptNumber` | number | Bitbucket delivery attempt number |
18611861
| `actor` | json | User or app that caused the event |
18621862
| `repository` | json | Repository where the event occurred |
1863-
| `payload` | json | Full raw Bitbucket webhook payload |
1863+
| `payload` | json | Full parsed Bitbucket webhook payload |
18641864
| `pullRequest` | json | Bitbucket pull request object |
18651865
| `pullRequestId` | number | Repository-scoped pull request ID |
18661866
| `pullRequestTitle` | string | Pull request title |
@@ -1898,7 +1898,7 @@ Trigger workflow when a resolved comment is reopened on a Bitbucket pull request
18981898
| `attemptNumber` | number | Bitbucket delivery attempt number |
18991899
| `actor` | json | User or app that caused the event |
19001900
| `repository` | json | Repository where the event occurred |
1901-
| `payload` | json | Full raw Bitbucket webhook payload |
1901+
| `payload` | json | Full parsed Bitbucket webhook payload |
19021902
| `pullRequest` | json | Bitbucket pull request object |
19031903
| `pullRequestId` | number | Repository-scoped pull request ID |
19041904
| `pullRequestTitle` | string | Pull request title |
@@ -1936,7 +1936,7 @@ Trigger workflow when a comment is resolved on a Bitbucket pull request
19361936
| `attemptNumber` | number | Bitbucket delivery attempt number |
19371937
| `actor` | json | User or app that caused the event |
19381938
| `repository` | json | Repository where the event occurred |
1939-
| `payload` | json | Full raw Bitbucket webhook payload |
1939+
| `payload` | json | Full parsed Bitbucket webhook payload |
19401940
| `pullRequest` | json | Bitbucket pull request object |
19411941
| `pullRequestId` | number | Repository-scoped pull request ID |
19421942
| `pullRequestTitle` | string | Pull request title |
@@ -1974,7 +1974,7 @@ Trigger workflow when a comment is updated on a Bitbucket pull request
19741974
| `attemptNumber` | number | Bitbucket delivery attempt number |
19751975
| `actor` | json | User or app that caused the event |
19761976
| `repository` | json | Repository where the event occurred |
1977-
| `payload` | json | Full raw Bitbucket webhook payload |
1977+
| `payload` | json | Full parsed Bitbucket webhook payload |
19781978
| `pullRequest` | json | Bitbucket pull request object |
19791979
| `pullRequestId` | number | Repository-scoped pull request ID |
19801980
| `pullRequestTitle` | string | Pull request title |
@@ -2012,7 +2012,7 @@ Trigger workflow when a Bitbucket pull request is created
20122012
| `attemptNumber` | number | Bitbucket delivery attempt number |
20132013
| `actor` | json | User or app that caused the event |
20142014
| `repository` | json | Repository where the event occurred |
2015-
| `payload` | json | Full raw Bitbucket webhook payload |
2015+
| `payload` | json | Full parsed Bitbucket webhook payload |
20162016
| `pullRequest` | json | Bitbucket pull request object |
20172017
| `pullRequestId` | number | Repository-scoped pull request ID |
20182018
| `pullRequestTitle` | string | Pull request title |
@@ -2047,7 +2047,7 @@ Trigger workflow when a Bitbucket pull request is declined
20472047
| `attemptNumber` | number | Bitbucket delivery attempt number |
20482048
| `actor` | json | User or app that caused the event |
20492049
| `repository` | json | Repository where the event occurred |
2050-
| `payload` | json | Full raw Bitbucket webhook payload |
2050+
| `payload` | json | Full parsed Bitbucket webhook payload |
20512051
| `pullRequest` | json | Bitbucket pull request object |
20522052
| `pullRequestId` | number | Repository-scoped pull request ID |
20532053
| `pullRequestTitle` | string | Pull request title |
@@ -2082,7 +2082,7 @@ Trigger workflow when a Bitbucket pull request is merged
20822082
| `attemptNumber` | number | Bitbucket delivery attempt number |
20832083
| `actor` | json | User or app that caused the event |
20842084
| `repository` | json | Repository where the event occurred |
2085-
| `payload` | json | Full raw Bitbucket webhook payload |
2085+
| `payload` | json | Full parsed Bitbucket webhook payload |
20862086
| `pullRequest` | json | Bitbucket pull request object |
20872087
| `pullRequestId` | number | Repository-scoped pull request ID |
20882088
| `pullRequestTitle` | string | Pull request title |
@@ -2117,7 +2117,7 @@ Trigger workflow when a Bitbucket pull request is updated
21172117
| `attemptNumber` | number | Bitbucket delivery attempt number |
21182118
| `actor` | json | User or app that caused the event |
21192119
| `repository` | json | Repository where the event occurred |
2120-
| `payload` | json | Full raw Bitbucket webhook payload |
2120+
| `payload` | json | Full parsed Bitbucket webhook payload |
21212121
| `pullRequest` | json | Bitbucket pull request object |
21222122
| `pullRequestId` | number | Repository-scoped pull request ID |
21232123
| `pullRequestTitle` | string | Pull request title |
@@ -2152,7 +2152,7 @@ Trigger workflow when commits are pushed to a Bitbucket repository
21522152
| `attemptNumber` | number | Bitbucket delivery attempt number |
21532153
| `actor` | json | User or app that caused the event |
21542154
| `repository` | json | Repository where the event occurred |
2155-
| `payload` | json | Full raw Bitbucket webhook payload |
2155+
| `payload` | json | Full parsed Bitbucket webhook payload |
21562156
| `push` | json | Push details, including changes and commits |
21572157

21582158

@@ -2182,7 +2182,7 @@ Trigger workflow when a Bitbucket repository is forked
21822182
| `attemptNumber` | number | Bitbucket delivery attempt number |
21832183
| `actor` | json | User or app that caused the event |
21842184
| `repository` | json | Repository where the event occurred |
2185-
| `payload` | json | Full raw Bitbucket webhook payload |
2185+
| `payload` | json | Full parsed Bitbucket webhook payload |
21862186
| `fork` | json | Newly created repository fork |
21872187

21882188

@@ -2212,6 +2212,6 @@ Trigger workflow when a Bitbucket repository is updated
22122212
| `attemptNumber` | number | Bitbucket delivery attempt number |
22132213
| `actor` | json | User or app that caused the event |
22142214
| `repository` | json | Repository where the event occurred |
2215-
| `payload` | json | Full raw Bitbucket webhook payload |
2215+
| `payload` | json | Full parsed Bitbucket webhook payload |
22162216
| `changes` | json | Repository fields changed by the update |
22172217

apps/docs/content/docs/en/platform/self-hosting/integrations-oauth.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,10 @@ The same variables also power "Sign in with Microsoft".
150150
For Bitbucket, create an OAuth consumer and register
151151
`https://<your-domain>/api/auth/oauth2/callback/bitbucket` as its callback URL. Bitbucket fixes
152152
permissions on the consumer instead of narrowing them per authorization request. Enable exactly
153-
Account read, Repositories read/write, Pull requests read/write, and Pipelines read/write
154-
(`account`, `repository`, `repository:write`, `pullrequest`, `pullrequest:write`, `pipeline`, and
155-
`pipeline:write`). Webhook permission is not required for the integration-only release.
153+
Account read, Repositories read/write, Pull requests read/write, Pipelines read/write, and Webhooks
154+
read/write (`account`, `repository`, `repository:write`, `pullrequest`, `pullrequest:write`,
155+
`pipeline`, `pipeline:write`, and `webhook`). The webhook permission is required for automatic
156+
trigger subscription management.
156157

157158
### Services with a different flow
158159

apps/sim/lib/oauth/oauth.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,29 @@ describe('Bitbucket OAuth Connector', () => {
190190
})
191191
})
192192

193+
it('normalizes Bitbucket’s singular scope response field', async () => {
194+
const getToken = getBitbucketConnector().getToken
195+
if (!getToken) throw new Error('Bitbucket connector must define getToken')
196+
197+
const tokens = await withMockFetch(
198+
createMockFetch({
199+
json: {
200+
access_token: 'bitbucket_access_token',
201+
refresh_token: 'bitbucket_refresh_token',
202+
scope: 'account repository pullrequest webhook',
203+
token_type: 'bearer',
204+
},
205+
}),
206+
() =>
207+
getToken({
208+
code: 'authorization_code',
209+
redirectURI: 'http://localhost:3000/api/auth/oauth2/callback/bitbucket',
210+
})
211+
)
212+
213+
expect(tokens.scopes).toEqual(['account', 'repository', 'pullrequest', 'webhook'])
214+
})
215+
193216
it('uses account_id before uuid and always synthesizes an internal email', async () => {
194217
const connector = getBitbucketConnector()
195218
const getUserInfo = connector.getUserInfo

0 commit comments

Comments
 (0)