Commit Graph
252 Commits
Author SHA1 Message Date
Myers Carpenter 53d01657c6 Fix OAuth token refresh race condition with singleflight (#6153) 2026-02-24 16:45:50 +01:00
renovate[bot]andlnx01 e7a7b1dbdd fix(deps): update module github.com/google/go-github/v82 to v83 (#6140)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-21 09:20:41 +01:00
qwerty287 b7c942984a Use tabs for indentation in embedded JSON (#6103) 2026-02-18 13:20:34 +01:00
qwerty287 bb4146da2a Fix BB email (#6102) 2026-02-11 07:42:31 +01:00
qwerty287 92a489f538 Refresh token before use for all forges (#6062) 2026-02-06 13:35:38 +01:00
6543 52cb9f6c21 Document required forge methods (#6049) 2026-02-03 17:04:24 +01:00
Kevin Web 894ba77d94 Fix OAuth token refresh in webhook handling for Bitbucket and GitHub (#6059)
## Summary

Fixes #5590
Fixes #5713

This PR fixes an issue where webhook handling fails with "failure to parse hook" error when the user's OAuth access token has expired. The root cause is that the Bitbucket and GitHub forge implementations make API calls during webhook processing without first refreshing the OAuth token.

## Problem

When a webhook arrives from Bitbucket or GitHub, the `Hook()` function (and its helper functions) make API calls to fetch additional data (changed files, repo info, etc.). These API calls use the stored OAuth access token, which may have expired.

**Before this fix:**
1. Webhook arrives
2. `Hook()` makes API calls with potentially expired token
3. API call fails with "OAuth2 access token expired"
4. Error bubbles up as HTTP 400 "failure to parse hook"
5. `forge.Refresh()` is called later in `PostHook()` - but it's too late

**Example error from logs:**

`failure to parse hook error="OAuth2 access token expired. Use your refresh token to obtain a new access token."`


## Solution

Add `forge.Refresh()` calls before making API calls in the webhook handling code paths. This follows the same pattern already used by:
- Bitbucket Data Center forge (`server/forge/bitbucketdatacenter/bitbucketdatacenter.go`)
- Other code paths like `pipeline.Create()`, `cron.go`, etc.

### Changes

**Bitbucket** (`server/forge/bitbucket/bitbucket.go`):
- Added `forge.Refresh()` in `Hook()` before API calls

**GitHub** (`server/forge/github/github.go`):
- Added `forge.Refresh()` in `loadChangedFilesFromPullRequest()`
- Added `forge.Refresh()` in `getTagCommitSHA()`
- Added `forge.Refresh()` in `loadChangedFilesFromCommits()`

## Testing

- All existing Bitbucket and GitHub forge tests pass
- Tested in production environment with Bitbucket (waited for token expiry, webhook succeeded after fix)
2026-02-03 13:34:01 +01:00
57b2449bb1 fix(deps): update golang-packages (#6058)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: qwerty287 <qwerty287@posteo.de>
2026-02-03 08:26:49 +01:00
6a33483647 fix(deps): update module github.com/google/go-github/v81 to v82 (#6047)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: qwerty287 <qwerty287@posteo.de>
2026-01-31 08:52:23 +01:00
6543 c3d1849673 Delete/Deactivate repo ignores missing repo at forge (#5953) 2026-01-11 13:00:27 +02:00
renovate[bot]andlnx01 8810f9722c fix(deps): update module github.com/google/go-github/v80 to v81 (#5946)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-10 14:22:28 +01:00
qwerty287 2f0684f502 Revert repos pagination for GH and BB (#5924) 2026-01-08 12:32:32 +01:00
qwerty287 2c82972f33 Log addon errors (#5923) 2026-01-08 11:28:58 +02:00
John Olheiser e23829397c fix: send correct argument to rpc call for name/url (#5922)
Signed-off-by: jolheiser <git@jolheiser.com>
2026-01-08 08:00:52 +01:00
renovate[bot]andlnx01 9cb353e103 fix(deps): update module github.com/google/go-github/v79 to v80 (#5838)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-06 20:46:28 +01:00
6543 761cc67f11 server/forge: rename var to be more descriptive and test value (#5806) 2025-12-02 13:40:08 +01:00
18ff3b7597 fix(deps): update module gitlab.com/gitlab-org/api/client-go to v1 (#5794)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: qwerty287 <qwerty287@posteo.de>
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
2025-11-29 09:54:07 +01:00
Erik Mogensen 88020fe1ca fix(bitbucketdatacenter): fix CI_COMMIT_PULL_REQUEST (#5769) 2025-11-27 09:49:11 +01:00
6543 21ef4cac53 On set/get of repo make sure forge_id is set and on fetch respected (#5717) 2025-11-27 09:39:41 +01:00
AnbratenandCopilot 92b48f813a Improve repair endpoints (#5767)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-20 22:44:05 +01:00
Harri Avellanandqwerty287 5b279af21a feat(bitbucketserver): get changes from all commits in a single push event (#5748)
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
2025-11-18 17:42:21 +01:00
renovate[bot]andlnx01 2279bb71cb fix(deps): update module github.com/google/go-github/v78 to v79 (#5757)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-15 16:00:37 +01:00
guillaumemandGuillaumeMeurillon 58f01089a5 Support for file changes in Bitbucket Cloud (#5730)
Co-authored-by: GuillaumeMeurillon <MeurillonGuillaume@users.noreply.github.com>
2025-11-12 17:29:23 +01:00
renovate[bot]andlnx01 6d48274e07 fix(deps): update module github.com/google/go-github/v77 to v78 (#5739)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-08 19:47:19 +01:00
df941c788a fix(deps): update module github.com/google/go-github/v76 to v77 (#5737)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
2025-11-08 14:45:23 +01:00
Han Cenandqwerty287 14320372e3 Fix workflow path filter for GitHub (#5721)
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
2025-11-06 08:52:50 +01:00
LUKIEYF 40f847b944 Add Header User-Agent for request client (#5664)
add Header User-Agent for request client for more precise in recognized the http request from.

close #3778
2025-11-05 11:41:48 +01:00
6543 800e8eb17f Revert to forge internal implementation of pagination for Repos() and Teams() for gitea/forgejo (#5679) 2025-11-02 23:16:01 +02:00
6543 fbaa339863 Fix nil pointer dereference during GitHub Hook parsing (#5681) 2025-10-23 20:44:41 +02:00
6543 6fa163514b Allow username to be used with multiple forges (#5676) 2025-10-23 17:28:01 +02:00
6543 c77ca3eb33 Create GitHub forge via WebUI fails to be created (#5675) 2025-10-23 14:44:37 +02:00
6543 37f1cdc0e9 Bitbucket: ignore push hooks with no changes propperly (#5672) 2025-10-23 12:53:59 +02:00
Henrik Huitti f9380cdf01 fix(bitbucketdatacenter): prevent adding new repos with empty branch (#5669) 2025-10-22 08:19:20 +02:00
1019d85065 Add log service addon (#5507)
Co-authored-by: Robert Kaussow <xoxys@rknet.org>
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
2025-10-21 08:40:30 +02:00
renovate[bot]andlnx01 0a5ceec40e fix(deps): update module github.com/google/go-github/v75 to v76 (#5652)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-18 09:06:05 +02:00
6543 f93ef16fe3 Add pagination for Repos() and Teams() in Forge interface (#5638) 2025-10-15 22:21:24 +02:00
6543 30e4383792 Document Forge interface precisely (#5636) 2025-10-14 01:38:10 +02:00
Robert Kaussow dd06fbcc61 Switch to GitHub REST API to load changed files (#5618)
Co-authored-by: 6543 <6543@obermui.de>

```
// GitHub has removed commit summaries from Events API payloads from 7th October 2025 onwards.
```

- switch to rest api to load changed files
- added some small wording/var name adjustment
- added test cases using GitHub mock client
2025-10-10 14:19:41 +02:00
Martin Schmidt 36187dea8c Enhance Bitbucket Datacenter build status reporting (#5611)
Improve build status reporting by adding duration, date added, and parent context to the status response.
The parent field enables `Required builds` to be set in bitbucket datacenter, to block merges to main before tests pass.
2025-10-08 12:48:03 +02:00
Henrik HuittiandRobert Kaussow 99dee0924a Support for pull requests opened events from forked repositories (#5536)
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
2025-09-28 08:54:53 +02:00
6543andqwerty287 388557d94a New event pull request metadata (#5214)
Co-authored-by: qwerty287 <qwerty287@posteo.de>
2025-09-25 00:07:45 +02:00
Robert Kaussow 2f3c4a28c1 Migrate to mockery v3 (#5547) 2025-09-24 13:12:55 +02:00
Robert Kaussow 8a69a1cfc6 Fix formatting and version formatting tools (#5540) 2025-09-23 00:36:46 +02:00
qwerty287 6d5bb97b40 Fix dir not found handling (#5533) 2025-09-21 12:11:35 +02:00
Henrik Huitti 275c8fee1c feat(bitbucketdatacenter): Implement missing OrgMembership method (#5476) 2025-09-21 09:51:30 +02:00
6543 c5a5bbea5d Add milestone to metadata (#5174) 2025-09-01 16:12:54 +02:00
AnbratenandAnton Bracke 24ebcb8cf8 Rename oauth variables (#5435)
Co-authored-by: Anton Bracke <anton.bracke@fastleansmart.com>
2025-08-20 22:47:43 +02:00
qwerty287 b4b4c68b72 Fix bitbucket status sending (#5372) 2025-08-10 19:51:16 +02:00
6543 f080070684 Count reopening an pull as opening an pull (#5370) 2025-08-05 23:02:36 +02:00
renovate[bot]andlnx01 dd4b2897a8 fix(deps): update module github.com/google/go-github/v73 to v74 (#5363)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-26 08:27:36 +03:00