diff --git a/CHANGELOG.md b/CHANGELOG.md index 78257144..a221b5a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - [ask sb] Fixed issue where reasoning tokens would appear in `text` content for openai compatible models. [#582](https://github.com/sourcebot-dev/sourcebot/pull/582) +- Fixed issue with GitHub app token tracking and refreshing. [#583](https://github.com/sourcebot-dev/sourcebot/pull/583) ## [4.8.1] - 2025-10-29 diff --git a/packages/backend/src/ee/githubAppManager.ts b/packages/backend/src/ee/githubAppManager.ts index ad4aa247..ffe5f529 100644 --- a/packages/backend/src/ee/githubAppManager.ts +++ b/packages/backend/src/ee/githubAppManager.ts @@ -16,9 +16,6 @@ type Installation = { login: string; type: 'organization' | 'user'; }; - createdAt: string; - expiresAt: string; - token: string; }; export class GithubAppManager { @@ -83,9 +80,6 @@ export class GithubAppManager { const owner = installationData.account.login; const accountType = installationData.account.type.toLowerCase() as 'organization' | 'user'; - const installationOctokit = await octokitApp.getInstallationOctokit(installationData.id); - const auth = await installationOctokit.auth({ type: "installation" }) as { expires_at: string, token: string }; - const installation: Installation = { id: installationData.id, appId: Number(app.id), @@ -93,9 +87,6 @@ export class GithubAppManager { login: owner, type: accountType, }, - createdAt: installationData.created_at, - expiresAt: auth.expires_at, - token: auth.token }; this.installationMap.set(this.generateMapKey(owner, deploymentHostname), installation); } @@ -113,22 +104,10 @@ export class GithubAppManager { throw new Error(`GitHub App Installation not found for ${key}`); } - if (installation.expiresAt < new Date().toISOString()) { - const octokitApp = this.octokitApps.get(installation.appId) as App; - const installationOctokit = await octokitApp.getInstallationOctokit(installation.id); - const auth = await installationOctokit.auth({ type: "installation" }) as { expires_at: string, token: string }; - - const newInstallation: Installation = { - ...installation, - expiresAt: auth.expires_at, - token: auth.token - }; - this.installationMap.set(key, newInstallation); - - return newInstallation.token; - } else { - return installation.token; - } + const octokitApp = this.octokitApps.get(installation.appId) as App; + const installationOctokit = await octokitApp.getInstallationOctokit(installation.id); + const auth = await installationOctokit.auth({ type: "installation" }) as { expires_at: string, token: string }; + return auth.token; } public appsConfigured() {