From d52b272a8256eb32e88bc349834bf9501c631815 Mon Sep 17 00:00:00 2001 From: Alex Ross <38270282+alexr00@users.noreply.github.com> Date: Mon, 27 Apr 2026 16:42:36 +0200 Subject: [PATCH 1/2] Better GraphQL error logging --- src/github/githubRepository.ts | 14 +------------- src/github/loggingOctokit.ts | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/github/githubRepository.ts b/src/github/githubRepository.ts index ae57ae9285..e761abcdf9 100644 --- a/src/github/githubRepository.ts +++ b/src/github/githubRepository.ts @@ -55,7 +55,7 @@ import { User, } from './interface'; import { IssueChangeEvent, IssueModel } from './issueModel'; -import { getErrorCode, LoggingOctokit } from './loggingOctokit'; +import { getErrorCode, GraphQLError, LoggingOctokit } from './loggingOctokit'; import { PullRequestModel } from './pullRequestModel'; import defaultSchema from './queries.gql'; import * as extraSchema from './queriesExtra.gql'; @@ -162,18 +162,6 @@ export interface ForkDetails { export type IMetadata = OctokitCommon.ReposGetResponseData; -export enum GraphQLErrorType { - Unprocessable = 'UNPROCESSABLE', -} - -export interface GraphQLError { - extensions?: { - code: string; - }; - type?: GraphQLErrorType; - message?: string; -} - export enum CopilotWorkingStatus { NotCopilotIssue = 'NotCopilotIssue', InProgress = 'InProgress', diff --git a/src/github/loggingOctokit.ts b/src/github/loggingOctokit.ts index 5fc39ba634..f1c6e9cc81 100644 --- a/src/github/loggingOctokit.ts +++ b/src/github/loggingOctokit.ts @@ -28,6 +28,18 @@ interface RateLimitResult { } | undefined; } +export enum GraphQLErrorType { + Unprocessable = 'UNPROCESSABLE', +} + +export interface GraphQLError { + extensions?: { + code: string; + }; + type?: GraphQLErrorType; + message?: string; +} + function isObject(value: unknown): value is Record { return typeof value === 'object' && value !== null; } @@ -47,12 +59,14 @@ export function getErrorCode(e: unknown): string | undefined { } const graphQLErrors = e.graphQLErrors; - if (Array.isArray(graphQLErrors)) { - const firstGraphQLError = graphQLErrors[0]; - if (isObject(firstGraphQLError)) { - const extensions = firstGraphQLError.extensions; - if (isObject(extensions) && extensions.code !== undefined) { - return String(extensions.code); + if (Array.isArray(graphQLErrors) && graphQLErrors.length > 0) { + const firstGraphQLError = graphQLErrors[0] as GraphQLError | undefined; + if (firstGraphQLError) { + if (firstGraphQLError.extensions?.code !== undefined) { + return String(firstGraphQLError.extensions.code); + } + if (firstGraphQLError.type !== undefined) { + return String(firstGraphQLError.type); } } } From 7effc43e014ff4be2fc3dc135f477a9db4d91527 Mon Sep 17 00:00:00 2001 From: Alex Ross <38270282+alexr00@users.noreply.github.com> Date: Mon, 27 Apr 2026 16:51:03 +0200 Subject: [PATCH 2/2] thanks copilot --- src/github/pullRequestModel.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/github/pullRequestModel.ts b/src/github/pullRequestModel.ts index 74b7be8c69..c6c0b18f58 100644 --- a/src/github/pullRequestModel.ts +++ b/src/github/pullRequestModel.ts @@ -13,7 +13,7 @@ import { ConflictResolutionModel } from './conflictResolutionModel'; import { CredentialStore } from './credentials'; import { showEmptyCommitWebview } from './emptyCommitWebview'; import { FolderRepositoryManager } from './folderRepositoryManager'; -import { GitHubRepository, GraphQLError, GraphQLErrorType } from './githubRepository'; +import { GitHubRepository } from './githubRepository'; import { AddCommentResponse, AddReactionResponse, @@ -66,7 +66,7 @@ import { ReviewEventEnum, } from './interface'; import { IssueChangeEvent, IssueModel } from './issueModel'; -import { compareCommits } from './loggingOctokit'; +import { compareCommits, GraphQLError, GraphQLErrorType } from './loggingOctokit'; import { convertRESTPullRequestToRawPullRequest, convertRESTReviewEvent,