Skip to content

Commit c2b530a

Browse files
authored
Fix/gh copilot apiversion (#8826)
* fix: changed apiversion of gh copilot as per the docs * fix: added test and a const for testable version
1 parent 94f7bca commit c2b530a

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

backend/plugins/gh-copilot/service/connection_test_helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func TestConnection(ctx stdctx.Context, br corectx.BasicRes, connection *models.
7373
}
7474
apiClient.SetHeaders(map[string]string{
7575
"Accept": "application/vnd.github+json",
76-
"X-GitHub-Api-Version": "2022-11-28",
76+
"X-GitHub-Api-Version": "2026-03-10",
7777
})
7878

7979
result := &TestConnectionResult{

backend/plugins/gh-copilot/tasks/api_client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import (
2828
"github.com/apache/incubator-devlake/plugins/gh-copilot/models"
2929
)
3030

31+
const gitHubApiVersion = "2026-03-10"
32+
3133
type nowFunc func() time.Time
3234
type sleepFunc func(time.Duration)
3335

@@ -65,7 +67,7 @@ func CreateApiClient(taskCtx plugin.TaskContext, connection *models.GhCopilotCon
6567

6668
apiClient.SetHeaders(map[string]string{
6769
"Accept": "application/vnd.github+json",
68-
"X-GitHub-Api-Version": "2022-11-28",
70+
"X-GitHub-Api-Version": gitHubApiVersion,
6971
})
7072

7173
rateLimiter := &helper.ApiRateLimitCalculator{UserRateLimitPerHour: connection.RateLimitPerHour}

backend/plugins/gh-copilot/tasks/api_client_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,8 @@ func TestHandleGitHubRetryAfterNoopOnNon429(t *testing.T) {
7575
require.Equal(t, time.Duration(0), slept)
7676
require.Len(t, logger.warnings, 0)
7777
}
78+
79+
func TestGitHubApiVersionHeaderValue(t *testing.T) {
80+
require.Equal(t, "2026-03-10", gitHubApiVersion,
81+
"GitHub API version header was changed; verify the new version is supported and update this test")
82+
}

0 commit comments

Comments
 (0)