Skip to content
Open
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
8 changes: 8 additions & 0 deletions pkg/errors/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ func NewGitHubAPIErrorToCtx(ctx context.Context, message string, resp *github.Re
return ctx, nil
}

func NewGitHubGraphQLErrorToCtx(ctx context.Context, message string, err error) (context.Context, error) {
graphQLErr := newGitHubGraphQLError(message, err)
if ctx != nil {
_, _ = addGitHubGraphQLErrorToContext(ctx, graphQLErr) // Explicitly ignore error for graceful handling
}
return ctx, nil
}

func addGitHubAPIErrorToContext(ctx context.Context, err *GitHubAPIError) (context.Context, error) {
if val, ok := ctx.Value(GitHubErrorKey{}).(*GitHubCtxErrors); ok {
val.api = append(val.api, err) // append the error to the existing slice in the context
Expand Down
16 changes: 12 additions & 4 deletions pkg/github/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,11 @@ func CreateIssue(ctx context.Context, client *github.Client, owner string, repo

issue, resp, err := client.Issues.Create(ctx, owner, repo, issueRequest)
if err != nil {
return utils.NewToolResultErrorFromErr("failed to create issue", err), nil
return ghErrors.NewGitHubAPIErrorResponse(ctx,
"failed to create issue",
resp,
err,
), nil
}
defer func() { _ = resp.Body.Close() }()

Expand Down Expand Up @@ -1522,7 +1526,11 @@ func ListIssues(t translations.TranslationHelperFunc) inventory.ServerTool {

issueQuery := getIssueQueryType(hasLabels, hasSince)
if err := client.Query(ctx, issueQuery, vars); err != nil {
return utils.NewToolResultError(err.Error()), nil, nil
return ghErrors.NewGitHubGraphQLErrorResponse(
ctx,
"failed to list issues",
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message capitalization is inconsistent. The message "failed to list issues" uses lowercase "failed", while other nearby error messages in this file use uppercase "Failed" (e.g., "Failed to get issue labels" at line 518, "Failed to find issues" at line 1265). For consistency, this should use "Failed to list issues" with an uppercase F to match the existing pattern in this file.

Suggested change
"failed to list issues",
"Failed to list issues",

Copilot uses AI. Check for mistakes.
err,
), nil, nil
}

// Extract and convert all issue nodes using the common interface
Expand Down Expand Up @@ -1683,7 +1691,7 @@ func AssignCopilotToIssue(t translations.TranslationHelperFunc) inventory.Server
var query suggestedActorsQuery
err := client.Query(ctx, &query, variables)
if err != nil {
return nil, nil, err
return ghErrors.NewGitHubGraphQLErrorResponse(ctx, "failed to get suggested actors", err), nil, nil
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message capitalization is inconsistent. The message "failed to get suggested actors" uses lowercase "failed", while other nearby error messages in this file use uppercase "Failed" (e.g., "Failed to get issue labels" at line 518, "Failed to find issues" at line 1265). For consistency, this should use "Failed to get suggested actors" with an uppercase F to match the existing pattern in this file.

Suggested change
return ghErrors.NewGitHubGraphQLErrorResponse(ctx, "failed to get suggested actors", err), nil, nil
return ghErrors.NewGitHubGraphQLErrorResponse(ctx, "Failed to get suggested actors", err), nil, nil

Copilot uses AI. Check for mistakes.
}

// Iterate all the returned nodes looking for the copilot bot, which is supposed to have the
Expand Down Expand Up @@ -1729,7 +1737,7 @@ func AssignCopilotToIssue(t translations.TranslationHelperFunc) inventory.Server
}

if err := client.Query(ctx, &getIssueQuery, variables); err != nil {
return utils.NewToolResultError(fmt.Sprintf("failed to get issue ID: %v", err)), nil, nil
return ghErrors.NewGitHubGraphQLErrorResponse(ctx, "failed to get issue ID", err), nil, nil
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message capitalization is inconsistent. The message "failed to get issue ID" uses lowercase "failed", while other nearby error messages in this file use uppercase "Failed" (e.g., "Failed to get issue labels" at line 518, "Failed to find issues" at line 1265). For consistency, this should use "Failed to get issue ID" with an uppercase F to match the existing pattern in this file.

Suggested change
return ghErrors.NewGitHubGraphQLErrorResponse(ctx, "failed to get issue ID", err), nil, nil
return ghErrors.NewGitHubGraphQLErrorResponse(ctx, "Failed to get issue ID", err), nil, nil

Copilot uses AI. Check for mistakes.
}

// Finally, do the assignment. Just for reference, assigning copilot to an issue that it is already
Expand Down
Loading