From b58323951aadf10edab31ae7ef69f222590831b0 Mon Sep 17 00:00:00 2001 From: Ulrik Andersen Date: Tue, 28 Apr 2026 07:56:10 +0200 Subject: [PATCH 1/4] Pin GitHub REST API version to suppress deprecation warnings Adds X-GitHub-Api-Version: 2022-11-28 header to all Octokit instances via a shared makeOctokit() helper. --- src/common/github/GitHubClient.ts | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/common/github/GitHubClient.ts b/src/common/github/GitHubClient.ts index 6a47674f..c7236db1 100644 --- a/src/common/github/GitHubClient.ts +++ b/src/common/github/GitHubClient.ts @@ -46,15 +46,19 @@ export default class GitHubClient implements IGitHubClient { } } + private makeOctokit(auth: string): Octokit { + return new Octokit({ auth, headers: { "X-GitHub-Api-Version": "2022-11-28" } }) + } + async graphql(request: GraphQLQueryRequest): Promise { const oauthToken = await this.oauthTokenDataSource.getOAuthToken() - const octokit = new Octokit({ auth: oauthToken.accessToken }) + const octokit = this.makeOctokit(oauthToken.accessToken) return await octokit.graphql(request.query, request.variables) } - + async getRepositoryContent(request: GetRepositoryContentRequest): Promise { const oauthToken = await this.oauthTokenDataSource.getOAuthToken() - const octokit = new Octokit({ auth: oauthToken.accessToken }) + const octokit = this.makeOctokit(oauthToken.accessToken) const response = await octokit.rest.repos.getContent({ owner: request.repositoryOwner, repo: request.repositoryName, @@ -64,10 +68,10 @@ export default class GitHubClient implements IGitHubClient { const item = response.data as GitHubContentItem return { downloadURL: item.download_url } } - + async getPullRequestFiles(request: GetPullRequestFilesRequest): Promise { const auth = await this.installationAuthenticator(request.appInstallationId) - const octokit = new Octokit({ auth: auth.token }) + const octokit = this.makeOctokit(auth.token) const files = await octokit.paginate(octokit.rest.pulls.listFiles, { owner: request.repositoryOwner, repo: request.repositoryName, @@ -77,10 +81,10 @@ export default class GitHubClient implements IGitHubClient { return { filename: file.filename, status: file.status } }) } - + async getPullRequestComments(request: GetPullRequestCommentsRequest): Promise { const auth = await this.installationAuthenticator(request.appInstallationId) - const octokit = new Octokit({ auth: auth.token }) + const octokit = this.makeOctokit(auth.token) const comments = await octokit.paginate(octokit.rest.issues.listComments, { owner: request.repositoryOwner, repo: request.repositoryName, @@ -99,10 +103,10 @@ export default class GitHubClient implements IGitHubClient { } return result } - + async addCommentToPullRequest(request: AddCommentToPullRequestRequest): Promise { const auth = await this.installationAuthenticator(request.appInstallationId) - const octokit = new Octokit({ auth: auth.token }) + const octokit = this.makeOctokit(auth.token) await octokit.rest.issues.createComment({ owner: request.repositoryOwner, repo: request.repositoryName, @@ -110,10 +114,10 @@ export default class GitHubClient implements IGitHubClient { body: request.body }) } - + async updatePullRequestComment(request: UpdatePullRequestCommentRequest): Promise { const auth = await this.installationAuthenticator(request.appInstallationId) - const octokit = new Octokit({ auth: auth.token }) + const octokit = this.makeOctokit(auth.token) await octokit.rest.issues.updateComment({ comment_id: request.commentId, owner: request.repositoryOwner, @@ -124,7 +128,7 @@ export default class GitHubClient implements IGitHubClient { async compareCommitsWithBasehead(request: CompareCommitsRequest): Promise { const oauthToken = await this.oauthTokenDataSource.getOAuthToken() - const octokit = new Octokit({ auth: oauthToken.accessToken }) + const octokit = this.makeOctokit(oauthToken.accessToken) const response = await octokit.rest.repos.compareCommitsWithBasehead({ owner: request.repositoryOwner, repo: request.repositoryName, From 625458c552837de3a013dbdf14f885c5d359e2b8 Mon Sep 17 00:00:00 2001 From: Ulrik Andersen Date: Tue, 28 Apr 2026 11:52:42 +0200 Subject: [PATCH 2/4] Fix Octokit default headers placement Move X-GitHub-Api-Version into request.headers where Octokit actually reads default headers, not the ignored top-level headers field. --- src/common/github/GitHubClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/github/GitHubClient.ts b/src/common/github/GitHubClient.ts index c7236db1..5b29d93b 100644 --- a/src/common/github/GitHubClient.ts +++ b/src/common/github/GitHubClient.ts @@ -47,7 +47,7 @@ export default class GitHubClient implements IGitHubClient { } private makeOctokit(auth: string): Octokit { - return new Octokit({ auth, headers: { "X-GitHub-Api-Version": "2022-11-28" } }) + return new Octokit({ auth, request: { headers: { "X-GitHub-Api-Version": "2022-11-28" } } }) } async graphql(request: GraphQLQueryRequest): Promise { From 094e6f284870db0dfe04cf3bc32c12816c1a6874 Mon Sep 17 00:00:00 2001 From: Ulrik Andersen Date: Tue, 28 Apr 2026 11:57:42 +0200 Subject: [PATCH 3/4] Pass X-GitHub-Api-Version per request instead of constructor Octokit 5.0.5 does not propagate constructor-level headers to requests. The only reliable way to set the API version is on each REST call directly. --- src/common/github/GitHubClient.ts | 36 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/common/github/GitHubClient.ts b/src/common/github/GitHubClient.ts index 5b29d93b..9ea42c4a 100644 --- a/src/common/github/GitHubClient.ts +++ b/src/common/github/GitHubClient.ts @@ -15,6 +15,8 @@ import IGitHubClient, { PullRequestFile } from "./IGitHubClient" +const GITHUB_API_VERSION = { "X-GitHub-Api-Version": "2022-11-28" } as const + interface IGitHubOAuthTokenDataSource { getOAuthToken(): Promise<{ accessToken: string }> } @@ -26,7 +28,7 @@ type InstallationAuthenticator = (installationId: number) => Promise<{token: str export default class GitHubClient implements IGitHubClient { private readonly oauthTokenDataSource: IGitHubOAuthTokenDataSource private readonly installationAuthenticator: InstallationAuthenticator - + constructor(config: { appId: string clientId: string @@ -45,25 +47,22 @@ export default class GitHubClient implements IGitHubClient { return await appAuth({ type: "installation", installationId }) } } - - private makeOctokit(auth: string): Octokit { - return new Octokit({ auth, request: { headers: { "X-GitHub-Api-Version": "2022-11-28" } } }) - } async graphql(request: GraphQLQueryRequest): Promise { const oauthToken = await this.oauthTokenDataSource.getOAuthToken() - const octokit = this.makeOctokit(oauthToken.accessToken) + const octokit = new Octokit({ auth: oauthToken.accessToken }) return await octokit.graphql(request.query, request.variables) } async getRepositoryContent(request: GetRepositoryContentRequest): Promise { const oauthToken = await this.oauthTokenDataSource.getOAuthToken() - const octokit = this.makeOctokit(oauthToken.accessToken) + const octokit = new Octokit({ auth: oauthToken.accessToken }) const response = await octokit.rest.repos.getContent({ owner: request.repositoryOwner, repo: request.repositoryName, path: request.path, - ref: request.ref + ref: request.ref, + headers: GITHUB_API_VERSION }) const item = response.data as GitHubContentItem return { downloadURL: item.download_url } @@ -71,11 +70,12 @@ export default class GitHubClient implements IGitHubClient { async getPullRequestFiles(request: GetPullRequestFilesRequest): Promise { const auth = await this.installationAuthenticator(request.appInstallationId) - const octokit = this.makeOctokit(auth.token) + const octokit = new Octokit({ auth: auth.token }) const files = await octokit.paginate(octokit.rest.pulls.listFiles, { owner: request.repositoryOwner, repo: request.repositoryName, pull_number: request.pullRequestNumber, + headers: GITHUB_API_VERSION }) return files.map(file => { return { filename: file.filename, status: file.status } @@ -84,11 +84,12 @@ export default class GitHubClient implements IGitHubClient { async getPullRequestComments(request: GetPullRequestCommentsRequest): Promise { const auth = await this.installationAuthenticator(request.appInstallationId) - const octokit = this.makeOctokit(auth.token) + const octokit = new Octokit({ auth: auth.token }) const comments = await octokit.paginate(octokit.rest.issues.listComments, { owner: request.repositoryOwner, repo: request.repositoryName, issue_number: request.pullRequestNumber, + headers: GITHUB_API_VERSION }) const result: PullRequestComment[] = [] for await (const comment of comments) { @@ -106,33 +107,36 @@ export default class GitHubClient implements IGitHubClient { async addCommentToPullRequest(request: AddCommentToPullRequestRequest): Promise { const auth = await this.installationAuthenticator(request.appInstallationId) - const octokit = this.makeOctokit(auth.token) + const octokit = new Octokit({ auth: auth.token }) await octokit.rest.issues.createComment({ owner: request.repositoryOwner, repo: request.repositoryName, issue_number: request.pullRequestNumber, - body: request.body + body: request.body, + headers: GITHUB_API_VERSION }) } async updatePullRequestComment(request: UpdatePullRequestCommentRequest): Promise { const auth = await this.installationAuthenticator(request.appInstallationId) - const octokit = this.makeOctokit(auth.token) + const octokit = new Octokit({ auth: auth.token }) await octokit.rest.issues.updateComment({ comment_id: request.commentId, owner: request.repositoryOwner, repo: request.repositoryName, - body: request.body + body: request.body, + headers: GITHUB_API_VERSION }) } async compareCommitsWithBasehead(request: CompareCommitsRequest): Promise { const oauthToken = await this.oauthTokenDataSource.getOAuthToken() - const octokit = this.makeOctokit(oauthToken.accessToken) + const octokit = new Octokit({ auth: oauthToken.accessToken }) const response = await octokit.rest.repos.compareCommitsWithBasehead({ owner: request.repositoryOwner, repo: request.repositoryName, - basehead: `${request.baseRefOid}...${request.headRefOid}` + basehead: `${request.baseRefOid}...${request.headRefOid}`, + headers: GITHUB_API_VERSION }) return { mergeBaseSha: response.data.merge_base_commit.sha } } From 272775fa2b4b8d2010535dc0e03c29554bf8e308 Mon Sep 17 00:00:00 2001 From: Ulrik Andersen Date: Tue, 28 Apr 2026 11:59:18 +0200 Subject: [PATCH 4/4] Upgrade GitHub REST API version to 2026-03-10 --- src/common/github/GitHubClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/github/GitHubClient.ts b/src/common/github/GitHubClient.ts index 9ea42c4a..b06bcdee 100644 --- a/src/common/github/GitHubClient.ts +++ b/src/common/github/GitHubClient.ts @@ -15,7 +15,7 @@ import IGitHubClient, { PullRequestFile } from "./IGitHubClient" -const GITHUB_API_VERSION = { "X-GitHub-Api-Version": "2022-11-28" } as const +const GITHUB_API_VERSION = { "X-GitHub-Api-Version": "2026-03-10" } as const interface IGitHubOAuthTokenDataSource { getOAuthToken(): Promise<{ accessToken: string }>