Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
29 changes: 4 additions & 25 deletions packages/backend/src/ee/githubAppManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ type Installation = {
login: string;
type: 'organization' | 'user';
};
createdAt: string;
expiresAt: string;
token: string;
};

export class GithubAppManager {
Expand Down Expand Up @@ -83,19 +80,13 @@ 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),
account: {
login: owner,
type: accountType,
},
createdAt: installationData.created_at,
expiresAt: auth.expires_at,
token: auth.token
};
this.installationMap.set(this.generateMapKey(owner, deploymentHostname), installation);
}
Expand All @@ -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() {
Expand Down
Loading