Skip to content

Commit a2f45a2

Browse files
fix: preserve agent tasks docs api version
1 parent f8042ad commit a2f45a2

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

github/agent_tasks.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ type CreateAgentTaskOptions struct {
114114

115115
// ListByRepo lists tasks for a repository.
116116
//
117-
// GitHub API docs: https://docs.github.com/rest/agent-tasks/agent-tasks?apiVersion=2022-11-28#list-tasks-for-repository
117+
// GitHub API docs: https://docs.github.com/rest/agent-tasks/agent-tasks?apiVersion=2026-03-10#list-tasks-for-repository
118118
//
119119
//meta:operation GET /agents/repos/{owner}/{repo}/tasks
120120
func (s *AgentTasksService) ListByRepo(ctx context.Context, owner, repo string, opts *AgentTaskListByRepoOptions) (*AgentTaskList, *Response, error) {
@@ -140,7 +140,7 @@ func (s *AgentTasksService) ListByRepo(ctx context.Context, owner, repo string,
140140

141141
// Create starts a new Copilot cloud agent task for a repository.
142142
//
143-
// GitHub API docs: https://docs.github.com/rest/agent-tasks/agent-tasks?apiVersion=2022-11-28#start-a-task
143+
// GitHub API docs: https://docs.github.com/rest/agent-tasks/agent-tasks?apiVersion=2026-03-10#start-a-task
144144
//
145145
//meta:operation POST /agents/repos/{owner}/{repo}/tasks
146146
func (s *AgentTasksService) Create(ctx context.Context, owner, repo string, opts *CreateAgentTaskOptions) (*AgentTask, *Response, error) {
@@ -162,7 +162,7 @@ func (s *AgentTasksService) Create(ctx context.Context, owner, repo string, opts
162162

163163
// GetByRepoAndID gets a repository task by ID.
164164
//
165-
// GitHub API docs: https://docs.github.com/rest/agent-tasks/agent-tasks?apiVersion=2022-11-28#get-a-task-by-repo
165+
// GitHub API docs: https://docs.github.com/rest/agent-tasks/agent-tasks?apiVersion=2026-03-10#get-a-task-by-repo
166166
//
167167
//meta:operation GET /agents/repos/{owner}/{repo}/tasks/{task_id}
168168
func (s *AgentTasksService) GetByRepoAndID(ctx context.Context, owner, repo, taskID string) (*AgentTask, *Response, error) {
@@ -184,7 +184,7 @@ func (s *AgentTasksService) GetByRepoAndID(ctx context.Context, owner, repo, tas
184184

185185
// List lists tasks for the authenticated user.
186186
//
187-
// GitHub API docs: https://docs.github.com/rest/agent-tasks/agent-tasks?apiVersion=2022-11-28#list-tasks
187+
// GitHub API docs: https://docs.github.com/rest/agent-tasks/agent-tasks?apiVersion=2026-03-10#list-tasks
188188
//
189189
//meta:operation GET /agents/tasks
190190
func (s *AgentTasksService) List(ctx context.Context, opts *AgentTaskListOptions) (*AgentTaskList, *Response, error) {
@@ -210,7 +210,7 @@ func (s *AgentTasksService) List(ctx context.Context, opts *AgentTaskListOptions
210210

211211
// Get gets a task by ID for the authenticated user.
212212
//
213-
// GitHub API docs: https://docs.github.com/rest/agent-tasks/agent-tasks?apiVersion=2022-11-28#get-a-task-by-id
213+
// GitHub API docs: https://docs.github.com/rest/agent-tasks/agent-tasks?apiVersion=2026-03-10#get-a-task-by-id
214214
//
215215
//meta:operation GET /agents/tasks/{task_id}
216216
func (s *AgentTasksService) Get(ctx context.Context, taskID string) (*AgentTask, *Response, error) {

tools/metadata/metadata.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,10 @@ func methodOps(opsFile *operationsFile, cmap ast.CommentMap, fn *ast.FuncDecl) (
482482
// Keep this in sync with defaultAPIVersion in github/github.go.
483483
const metadataDocsAPIVersion = "2022-11-28"
484484

485+
var previewDocsAPIVersions = map[string]string{
486+
"/rest/agent-tasks/agent-tasks": "2026-03-10",
487+
}
488+
485489
// normalizeDocURL cleans docURL's path and enforces metadataDocsAPIVersion for
486490
// https://docs.github.com/rest and
487491
// https://docs.github.com/enterprise-cloud@latest/rest URLs.
@@ -503,7 +507,11 @@ func normalizeDocURL(docURL string) string {
503507
u.Path = cleanPath
504508
q := u.Query()
505509
if q.Get("apiVersion") == "" {
506-
q.Set("apiVersion", metadataDocsAPIVersion)
510+
apiVersion := metadataDocsAPIVersion
511+
if version, ok := previewDocsAPIVersions[cleanPath]; ok {
512+
apiVersion = version
513+
}
514+
q.Set("apiVersion", apiVersion)
507515
}
508516
u.RawQuery = q.Encode()
509517
return u.String()

tools/metadata/metadata_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ func Test_normalizeDocURL(t *testing.T) {
6262
docURL: "https://docs.github.com/rest/private-registries/organization-configurations?apiVersion=2026-03-10#list-private-registries-for-an-organization",
6363
want: "https://docs.github.com/rest/private-registries/organization-configurations?apiVersion=2026-03-10#list-private-registries-for-an-organization",
6464
},
65+
{
66+
name: "add preview api version",
67+
docURL: "https://docs.github.com/rest/agent-tasks/agent-tasks#list-tasks",
68+
want: "https://docs.github.com/rest/agent-tasks/agent-tasks?apiVersion=2026-03-10#list-tasks",
69+
},
6570
{
6671
name: "enterprise cloud latest rest is normalized",
6772
docURL: "https://docs.github.com/enterprise-cloud@latest/rest/repos/repos#get-a-repository",

0 commit comments

Comments
 (0)