From 752357e8bd41ec808e73ec6c6f35f262540e8214 Mon Sep 17 00:00:00 2001 From: Annie Gesellchen <10727170+cagesellchen@users.noreply.github.com> Date: Fri, 6 Nov 2026 14:34:50 -0800 Subject: [PATCH 1/5] Remove thread_resolution_reason feature flag The flag is globally enabled, so resolution reasons are now always available on pull_request_review_write and resolve_review_thread. GHES still omits the resolutionReason input because it does not support it. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- README.md | 1 + docs/feature-flags.md | 15 +--- .../pull_request_review_write.snap | 4 + ...equest_review_write_resolution_reason.snap | 81 ------------------- .../__toolsnaps__/resolve_review_thread.snap | 4 + ...solve_review_thread_resolution_reason.snap | 54 ------------- pkg/github/feature_flags.go | 4 - pkg/github/feature_flags_test.go | 28 ++----- pkg/github/granular_tools_test.go | 22 ++--- pkg/github/pullrequests.go | 42 ++-------- pkg/github/pullrequests_granular.go | 40 +-------- pkg/github/pullrequests_test.go | 25 +++--- pkg/github/tools.go | 7 +- ..._consolidated_pull_request_outputs_test.go | 22 ++--- ...yped_granular_pull_request_outputs_test.go | 32 +++----- 15 files changed, 69 insertions(+), 312 deletions(-) delete mode 100644 pkg/github/__toolsnaps__/pull_request_review_write_resolution_reason.snap delete mode 100644 pkg/github/__toolsnaps__/resolve_review_thread_resolution_reason.snap diff --git a/README.md b/README.md index 432541f434..d910312edf 100644 --- a/README.md +++ b/README.md @@ -1342,6 +1342,7 @@ For negotiated supported protocol versions `2026-07-28` or newer, the consolidat - `owner`: Repository owner (string, required) - `pullNumber`: Pull request number (number, required) - `repo`: Repository name (string, required) + - `resolutionReason`: Optional reason for resolving a Copilot code review thread: addressed, wont-fix, or invalid. (string, optional) - `threadId`: The node ID of the review thread (e.g., PRRT_kwDOxxx). Required for resolve_thread and unresolve_thread methods. Get thread IDs from pull_request_read with method get_review_comments. (string, optional) - **search_pull_requests** - Search pull requests diff --git a/docs/feature-flags.md b/docs/feature-flags.md index f3380ae010..6eb8ab24a5 100644 --- a/docs/feature-flags.md +++ b/docs/feature-flags.md @@ -332,6 +332,7 @@ as output formatting) won't appear here. - **resolve_review_thread** - Resolve Review Thread - **OAuth Challenge Scopes**: `repo` + - `resolutionReason`: Optional reason for resolving a Copilot code review thread: addressed, wont-fix, or invalid. (string, optional) - `threadID`: The node ID of the review thread to resolve (e.g., PRRT_kwDOxxx) (string, required) - **submit_pending_pull_request_review** - Submit Pending Pull Request Review @@ -467,18 +468,4 @@ as output formatting) won't appear here. - `perPage`: Results per page for pagination (min 0, max 100). Zero is forwarded for the GitHub API default. (number, optional) - `repo`: The name of the repository (string, required) -### `thread_resolution_reason` - -- **pull_request_review_write** - Write operations (create, submit, delete) on pull request reviews - - **OAuth Challenge Scopes**: `repo` - - `body`: Review comment text (string, optional) - - `commitID`: SHA of commit to review (string, optional) - - `event`: Review action to perform. (string, optional) - - `method`: The write operation to perform on pull request review. (string, required) - - `owner`: Repository owner (string, required) - - `pullNumber`: Pull request number (number, required) - - `repo`: Repository name (string, required) - - `resolutionReason`: Optional reason for resolving a Copilot code review thread: addressed, wont-fix, or invalid. (string, optional) - - `threadId`: The node ID of the review thread (e.g., PRRT_kwDOxxx). Required for resolve_thread and unresolve_thread methods. Get thread IDs from pull_request_read with method get_review_comments. (string, optional) - diff --git a/pkg/github/__toolsnaps__/pull_request_review_write.snap b/pkg/github/__toolsnaps__/pull_request_review_write.snap index 70cf6471c1..45e19ca7bf 100644 --- a/pkg/github/__toolsnaps__/pull_request_review_write.snap +++ b/pkg/github/__toolsnaps__/pull_request_review_write.snap @@ -47,6 +47,10 @@ "description": "Repository name", "type": "string" }, + "resolutionReason": { + "description": "Optional reason for resolving a Copilot code review thread: addressed, wont-fix, or invalid.", + "type": "string" + }, "threadId": { "description": "The node ID of the review thread (e.g., PRRT_kwDOxxx). Required for resolve_thread and unresolve_thread methods. Get thread IDs from pull_request_read with method get_review_comments.", "type": "string" diff --git a/pkg/github/__toolsnaps__/pull_request_review_write_resolution_reason.snap b/pkg/github/__toolsnaps__/pull_request_review_write_resolution_reason.snap deleted file mode 100644 index 45e19ca7bf..0000000000 --- a/pkg/github/__toolsnaps__/pull_request_review_write_resolution_reason.snap +++ /dev/null @@ -1,81 +0,0 @@ -{ - "annotations": { - "idempotentHint": false, - "readOnlyHint": false, - "title": "Write operations (create, submit, delete) on pull request reviews" - }, - "description": "Create and/or submit, delete review of a pull request.\n\nAvailable methods:\n- create: Create a new review of a pull request. If \"event\" parameter is provided, the review is submitted. If \"event\" is omitted, a pending review is created.\n- submit_pending: Submit an existing pending review of a pull request. This requires that a pending review exists for the current user on the specified pull request. The \"body\" and \"event\" parameters are used when submitting the review.\n- delete_pending: Delete an existing pending review of a pull request. This requires that a pending review exists for the current user on the specified pull request.\n- resolve_thread: Resolve a review thread. Requires only \"threadId\" parameter with the thread's node ID (e.g., PRRT_kwDOxxx). The owner, repo, and pullNumber parameters are not used for this method. Resolving an already-resolved thread is a no-op.\n- unresolve_thread: Unresolve a previously resolved review thread. Requires only \"threadId\" parameter. The owner, repo, and pullNumber parameters are not used for this method. Unresolving an already-unresolved thread is a no-op.\n", - "inputSchema": { - "properties": { - "body": { - "description": "Review comment text", - "type": "string" - }, - "commitID": { - "description": "SHA of commit to review", - "type": "string" - }, - "event": { - "description": "Review action to perform.", - "enum": [ - "APPROVE", - "REQUEST_CHANGES", - "COMMENT" - ], - "type": "string" - }, - "method": { - "description": "The write operation to perform on pull request review.", - "enum": [ - "create", - "submit_pending", - "delete_pending", - "resolve_thread", - "unresolve_thread" - ], - "type": "string" - }, - "owner": { - "description": "Repository owner", - "type": "string" - }, - "pullNumber": { - "description": "Pull request number", - "type": "number" - }, - "repo": { - "description": "Repository name", - "type": "string" - }, - "resolutionReason": { - "description": "Optional reason for resolving a Copilot code review thread: addressed, wont-fix, or invalid.", - "type": "string" - }, - "threadId": { - "description": "The node ID of the review thread (e.g., PRRT_kwDOxxx). Required for resolve_thread and unresolve_thread methods. Get thread IDs from pull_request_read with method get_review_comments.", - "type": "string" - } - }, - "required": [ - "method", - "owner", - "repo", - "pullNumber" - ], - "type": "object" - }, - "name": "pull_request_review_write", - "outputSchema": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Operation result message.", - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } -} \ No newline at end of file diff --git a/pkg/github/__toolsnaps__/resolve_review_thread.snap b/pkg/github/__toolsnaps__/resolve_review_thread.snap index dc01720117..b8bf2c8c7d 100644 --- a/pkg/github/__toolsnaps__/resolve_review_thread.snap +++ b/pkg/github/__toolsnaps__/resolve_review_thread.snap @@ -21,6 +21,10 @@ ], "inputSchema": { "properties": { + "resolutionReason": { + "description": "Optional reason for resolving a Copilot code review thread: addressed, wont-fix, or invalid.", + "type": "string" + }, "threadID": { "description": "The node ID of the review thread to resolve (e.g., PRRT_kwDOxxx)", "type": "string" diff --git a/pkg/github/__toolsnaps__/resolve_review_thread_resolution_reason.snap b/pkg/github/__toolsnaps__/resolve_review_thread_resolution_reason.snap deleted file mode 100644 index b8bf2c8c7d..0000000000 --- a/pkg/github/__toolsnaps__/resolve_review_thread_resolution_reason.snap +++ /dev/null @@ -1,54 +0,0 @@ -{ - "annotations": { - "destructiveHint": false, - "idempotentHint": false, - "openWorldHint": true, - "readOnlyHint": false, - "title": "Resolve Review Thread" - }, - "description": "Resolve a review thread on a pull request. Resolving an already-resolved thread is a no-op.", - "icons": [ - { - "mimeType": "image/png", - "src": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAACwUlEQVRIie2Vz28UZRjHP993pi0QIC3YahNjirtmd3bS3Q1eUHvQEPUiEv8A4kXjwRJ78MCFBLjBBRKCHowHE38cNCbGGx6IUoKiodtNpoNmTJp4oSJNQ3pw29l5POxus2wo3QTwxPc0887zfD7zvu9kXnjEUfdNrjj5vJOmMP4e9JrfR1G02tuQD8tvgpck0dxCPwK30ViqnJTcr4bOmfRlI/PrhUJ5313woDpDpu8ss7f6nYHrvDnGcYlPsoY/bKaXwHY3HWfvgmNnMX0zvMM7069A3c3pkEYWa7UVgFxQPSfs7SSeH3k2rEy5jMubMBoG1yQ+SBbm53of+gCybMkk/H8VAFdbZisZLAFsJ11oyL+BUURcwrjWAZixXeIwxs/5UuVAr0QAYRjubGR+HWy3mb6QCIBXQe8nce0jgIkwfMo3/xLG085x8I9ofkMyUa0O+w2rgS0mcf3lboEDiKJo1cvsIDDr4D1DhTb8407hYhTdTJW+AvrdMnuhG9Je1m9BBzbfjXbyQcXypeqJLQt7+0rVE/mgYr3j7l7FDzOPBY8FDx6vc1EolPeNjI5/Jpgw7Lm9o+Pry//c/K0PhnLFyrSMDxE79jwxvn9079gvt28vrUD7V1EoFHalbltd2C7DfS4sAF4DTSdx7cL96LliZVriPPADuL+geRh0Z8il5SiKVn2ATENvCCYw78U/b8xdBcgHlYuGHQXuK5A4ClxM4vnXW8Lqp5JdWWt6h4CvWnsgxgDSbRZ3Gg0tCJ7sY4nGwDZOt/WBZtzN9FswLgM2sGann5mcPDaw5pWEHQH7cUu86SdkR3LF6tfrA814MNVpwNrM1leUxPXrSKfMeHcwdctyNotY8c3NbMX3LJsB3ZHsymDqlkHvYHYyievXWxPpSj4o75eYIuPWZof+vRKG4c61pncIx6gZsx34/5L/ACy3ElqUYhuvAAAAAElFTkSuQmCC", - "theme": "light" - }, - { - "mimeType": "image/png", - "src": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAABn0lEQVRIie2Vvy5EURDGvyMUkhUU/pS2Q2clwvIKqL0Cm9ArrBcQShJPoLFR2YaIhIjQ7a7E39IiCgqVn8KsPY697E3oTHPumTPf990z986M9Mfm/A0wKGlMUlnSlnPuOQQAE5LOnXOFWErAIvBK1S6BZBAzZ2fzcckHjXwVaAXSwD2wWYN8A2iKK1ABt3m+ZeDRnseIthdgDxioxd1o662tfZIO7Lnf8xcklST1StqRdORxNEualHQIDDvnTmvdIGE5vwdWgLy93bQX0w0UgSdgKMC3AdfA7ndpSgKbduUbYBoI/7Ju4BiYrYFfAl4iBbxAgOyPgV9xWYDQ3xCXKK79C/wL/KJZoeW8QpsJCy0C54AMULaGmQu7sIAW4MpaxTKwbQU3U4dAxmLzwLpxXAIJP2jKgkY8Xx4o1SFwBmx7+7RxTUnVb9Bpa9HDFiR1/SRgWH+6FT3/h2qK6sBpB0aBB7yB880NcpaWtGHXjCsVBmb5PDIvgJ46BJKW84q9AguV87Adp/Q+9O8UMfQjRBKSxiV1SNp3zp3Ug/sVewPruexhKwhGXQAAAABJRU5ErkJggg==", - "theme": "dark" - } - ], - "inputSchema": { - "properties": { - "resolutionReason": { - "description": "Optional reason for resolving a Copilot code review thread: addressed, wont-fix, or invalid.", - "type": "string" - }, - "threadID": { - "description": "The node ID of the review thread to resolve (e.g., PRRT_kwDOxxx)", - "type": "string" - } - }, - "required": [ - "threadID" - ], - "type": "object" - }, - "name": "resolve_review_thread", - "outputSchema": { - "additionalProperties": false, - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": [ - "null", - "object" - ] - } -} \ No newline at end of file diff --git a/pkg/github/feature_flags.go b/pkg/github/feature_flags.go index 4957c2f71e..da9b820227 100644 --- a/pkg/github/feature_flags.go +++ b/pkg/github/feature_flags.go @@ -39,9 +39,6 @@ const FeatureFlagIssueArtifacts = "issue_artifacts" // opt-in. const FeatureFlagDuplicateDetection = "duplicate_detection" -// FeatureFlagThreadResolutionReason exposes resolution reasons for Copilot review threads. -const FeatureFlagThreadResolutionReason = "thread_resolution_reason" - // AllowedFeatureFlags is the allowlist of feature flags that can be enabled // by users via --features CLI flag, X-MCP-Features HTTP header, or the // features URL query parameter. @@ -57,7 +54,6 @@ var AllowedFeatureFlags = []string{ FeatureFlagIssueDependencies, FeatureFlagIssueArtifacts, FeatureFlagDuplicateDetection, - FeatureFlagThreadResolutionReason, } // InsidersFeatureFlags is the list of feature flags that insiders mode enables. diff --git a/pkg/github/feature_flags_test.go b/pkg/github/feature_flags_test.go index 173a8cfd12..bc2ffb710d 100644 --- a/pkg/github/feature_flags_test.go +++ b/pkg/github/feature_flags_test.go @@ -201,11 +201,6 @@ func TestResolveFeatureFlags(t *testing.T) { insidersMode: false, expectedFlags: []string{FeatureFlagIssuesGranular}, }, - { - name: "thread resolution reason can be directly enabled", - enabledFeatures: []string{FeatureFlagThreadResolutionReason}, - expectedFlags: []string{FeatureFlagThreadResolutionReason}, - }, { name: "insiders does not enable user-only allowed flags", enabledFeatures: nil, @@ -243,35 +238,24 @@ func TestThreadResolutionReasonToolVariants(t *testing.T) { hasReason bool }{ { - name: "consolidated flag off", - toolName: "pull_request_review_write", - }, - { - name: "consolidated flag on", - flags: []inventory.FeatureFlag{FeatureFlagThreadResolutionReason}, + name: "consolidated", toolName: "pull_request_review_write", hasReason: true, }, { - name: "granular flag off", - flags: []inventory.FeatureFlag{inventory.FeatureFlag(FeatureFlagPullRequestsGranular)}, - toolName: "resolve_review_thread", - }, - { - name: "granular flag on", - flags: []inventory.FeatureFlag{inventory.FeatureFlag(FeatureFlagPullRequestsGranular), FeatureFlagThreadResolutionReason}, + name: "granular", + flags: []inventory.FeatureFlag{inventory.FeatureFlag(FeatureFlagPullRequestsGranular)}, toolName: "resolve_review_thread", hasReason: true, }, { - name: "consolidated flag on GHES", - flags: []inventory.FeatureFlag{FeatureFlagThreadResolutionReason}, + name: "consolidated GHES", host: utils.HostTypeGHES, toolName: "pull_request_review_write", }, { - name: "granular flag on GHES", - flags: []inventory.FeatureFlag{inventory.FeatureFlag(FeatureFlagPullRequestsGranular), FeatureFlagThreadResolutionReason}, + name: "granular GHES", + flags: []inventory.FeatureFlag{inventory.FeatureFlag(FeatureFlagPullRequestsGranular)}, host: utils.HostTypeGHES, toolName: "resolve_review_thread", }, diff --git a/pkg/github/granular_tools_test.go b/pkg/github/granular_tools_test.go index 460a192766..90888ab035 100644 --- a/pkg/github/granular_tools_test.go +++ b/pkg/github/granular_tools_test.go @@ -14,6 +14,7 @@ import ( transportpkg "github.com/github/github-mcp-server/v2/pkg/http/transport" "github.com/github/github-mcp-server/v2/pkg/inventory" "github.com/github/github-mcp-server/v2/pkg/translations" + "github.com/github/github-mcp-server/v2/pkg/utils" gogithub "github.com/google/go-github/v92/github" "github.com/shurcooL/githubv4" "github.com/stretchr/testify/assert" @@ -1711,18 +1712,17 @@ func TestGranularAddPullRequestReviewComment(t *testing.T) { func TestGranularResolveReviewThread(t *testing.T) { tests := []struct { - name string - withResolutionReason bool - resolutionReason *string - expectedReason *string + name string + ghes bool + resolutionReason *string + expectedReason *string }{ { - name: "enabled variant forwards resolution reason", - withResolutionReason: true, - resolutionReason: new("addressed"), - expectedReason: new("addressed"), + name: "forwards resolution reason", + resolutionReason: new("addressed"), + expectedReason: new("addressed"), }, - {name: "default variant omits resolution reason", resolutionReason: new("addressed")}, + {name: "GHES omits resolution reason", ghes: true, resolutionReason: new("addressed")}, {name: "without resolution reason"}, } @@ -1753,8 +1753,8 @@ func TestGranularResolveReviewThread(t *testing.T) { gqlClient := githubv4.NewClient(mockedClient) deps := BaseDeps{GQLClient: gqlClient} serverTool := GranularResolveReviewThread(translations.NullTranslationHelper) - if tc.withResolutionReason { - serverTool = GranularResolveReviewThreadWithResolutionReason(translations.NullTranslationHelper) + if tc.ghes { + serverTool = GranularResolveReviewThread(translations.NullTranslationHelper, WithHost(utils.HostTypeGHES)) } handler := serverTool.Handler(deps) diff --git a/pkg/github/pullrequests.go b/pkg/github/pullrequests.go index 70fdfa197a..bfe10bb307 100644 --- a/pkg/github/pullrequests.go +++ b/pkg/github/pullrequests.go @@ -1981,22 +1981,10 @@ type PullRequestReviewWriteParams struct { ResolutionReason *string } -func PullRequestReviewWrite(t translations.TranslationHelperFunc) inventory.ServerTool { - return pullRequestReviewWrite(t, false, toolConfig{}) -} - -// PullRequestReviewWriteWithResolutionReason creates the feature-gated review write variant with resolution reasons. -func PullRequestReviewWriteWithResolutionReason(t translations.TranslationHelperFunc, opts ...ToolOption) inventory.ServerTool { - cfg := newToolConfig(opts) - st := pullRequestReviewWrite(t, true, cfg) - if cfg.hostType == utils.HostTypeGHES { - st.Enabled = func(context.Context) (bool, error) { return false, nil } - } - return st -} - -func pullRequestReviewWrite(t translations.TranslationHelperFunc, withResolutionReason bool, cfg toolConfig) inventory.ServerTool { - withResolutionReason = withResolutionReason && cfg.hostType != utils.HostTypeGHES +// PullRequestReviewWrite creates the consolidated review write tool. Resolution +// reasons are omitted on GHES, which does not support them. +func PullRequestReviewWrite(t translations.TranslationHelperFunc, opts ...ToolOption) inventory.ServerTool { + withResolutionReason := newToolConfig(opts).hostType != utils.HostTypeGHES schema := &jsonschema.Schema{ Type: "object", @@ -2111,27 +2099,7 @@ Available methods: return utils.NewToolResultError(fmt.Sprintf("unknown method: %s", params.Method)), nil, nil } }, normalizePullRequestReviewWriteArguments) - if withResolutionReason { - st.FeatureRule = inventory.NewFeatureRule( - []inventory.FeatureFlag{FeatureFlagThreadResolutionReason, inventory.FeatureFlag(FeatureFlagPullRequestsGranular)}, - func(featureAsBool inventory.FeatureResolver) bool { - return featureAsBool(FeatureFlagThreadResolutionReason) && - !featureAsBool(inventory.FeatureFlag(FeatureFlagPullRequestsGranular)) - }, - ) - } else { - if cfg.hostType == utils.HostTypeGHES { - st.FeatureRule = pullRequestsConsolidatedRule - } else { - st.FeatureRule = inventory.NewFeatureRule( - []inventory.FeatureFlag{FeatureFlagThreadResolutionReason, inventory.FeatureFlag(FeatureFlagPullRequestsGranular)}, - func(featureAsBool inventory.FeatureResolver) bool { - return !featureAsBool(FeatureFlagThreadResolutionReason) && - !featureAsBool(inventory.FeatureFlag(FeatureFlagPullRequestsGranular)) - }, - ) - } - } + st.FeatureRule = pullRequestsConsolidatedRule return st } diff --git a/pkg/github/pullrequests_granular.go b/pkg/github/pullrequests_granular.go index 423a53114d..2c8713c91e 100644 --- a/pkg/github/pullrequests_granular.go +++ b/pkg/github/pullrequests_granular.go @@ -576,22 +576,9 @@ func GranularAddPullRequestReviewComment(t translations.TranslationHelperFunc) i } // GranularResolveReviewThread creates a tool to resolve a review thread. -func GranularResolveReviewThread(t translations.TranslationHelperFunc) inventory.ServerTool { - return granularResolveReviewThread(t, false, toolConfig{}) -} - -// GranularResolveReviewThreadWithResolutionReason creates the feature-gated variant with resolution reasons. -func GranularResolveReviewThreadWithResolutionReason(t translations.TranslationHelperFunc, opts ...ToolOption) inventory.ServerTool { - cfg := newToolConfig(opts) - st := granularResolveReviewThread(t, true, cfg) - if cfg.hostType == utils.HostTypeGHES { - st.Enabled = func(context.Context) (bool, error) { return false, nil } - } - return st -} - -func granularResolveReviewThread(t translations.TranslationHelperFunc, withResolutionReason bool, cfg toolConfig) inventory.ServerTool { - withResolutionReason = withResolutionReason && cfg.hostType != utils.HostTypeGHES +// Resolution reasons are omitted on GHES, which does not support them. +func GranularResolveReviewThread(t translations.TranslationHelperFunc, opts ...ToolOption) inventory.ServerTool { + withResolutionReason := newToolConfig(opts).hostType != utils.HostTypeGHES properties := map[string]*jsonschema.Schema{ "threadID": { @@ -645,26 +632,7 @@ func granularResolveReviewThread(t translations.TranslationHelperFunc, withResol }, normalizeGranularResolveReviewThreadArguments(withResolutionReason), ) - switch { - case withResolutionReason: - st.FeatureRule = inventory.NewFeatureRule( - []inventory.FeatureFlag{inventory.FeatureFlag(FeatureFlagPullRequestsGranular), FeatureFlagThreadResolutionReason}, - func(featureAsBool inventory.FeatureResolver) bool { - return featureAsBool(inventory.FeatureFlag(FeatureFlagPullRequestsGranular)) && - featureAsBool(FeatureFlagThreadResolutionReason) - }, - ) - case cfg.hostType == utils.HostTypeGHES: - st.FeatureRule = pullRequestsGranularFeatureRule - default: - st.FeatureRule = inventory.NewFeatureRule( - []inventory.FeatureFlag{inventory.FeatureFlag(FeatureFlagPullRequestsGranular), FeatureFlagThreadResolutionReason}, - func(featureAsBool inventory.FeatureResolver) bool { - return featureAsBool(inventory.FeatureFlag(FeatureFlagPullRequestsGranular)) && - !featureAsBool(FeatureFlagThreadResolutionReason) - }, - ) - } + st.FeatureRule = pullRequestsGranularFeatureRule return st } diff --git a/pkg/github/pullrequests_test.go b/pkg/github/pullrequests_test.go index 546094910c..c85ecf2c65 100644 --- a/pkg/github/pullrequests_test.go +++ b/pkg/github/pullrequests_test.go @@ -13,6 +13,7 @@ import ( "github.com/github/github-mcp-server/v2/internal/toolsnaps" "github.com/github/github-mcp-server/v2/pkg/inventory" "github.com/github/github-mcp-server/v2/pkg/translations" + "github.com/github/github-mcp-server/v2/pkg/utils" "github.com/google/go-github/v92/github" "github.com/google/jsonschema-go/jsonschema" "github.com/modelcontextprotocol/go-sdk/mcp" @@ -4758,13 +4759,13 @@ func TestResolveReviewThread(t *testing.T) { t.Parallel() tests := []struct { - name string - requestArgs map[string]any - mockedClient *http.Client - withResolutionReason bool - expectToolError bool - expectedToolErrMsg string - expectedResult string + name string + requestArgs map[string]any + mockedClient *http.Client + ghes bool + expectToolError bool + expectedToolErrMsg string + expectedResult string }{ { name: "successful resolve thread", @@ -4802,8 +4803,7 @@ func TestResolveReviewThread(t *testing.T) { expectedResult: "review thread resolved successfully", }, { - name: "successful resolve thread with resolution reason", - withResolutionReason: true, + name: "successful resolve thread with resolution reason", requestArgs: map[string]any{ "method": "resolve_thread", "owner": "owner", @@ -4840,7 +4840,8 @@ func TestResolveReviewThread(t *testing.T) { expectedResult: "review thread resolved successfully", }, { - name: "default variant omits resolution reason", + name: "GHES omits resolution reason", + ghes: true, requestArgs: map[string]any{ "method": "resolve_thread", "owner": "owner", @@ -4998,8 +4999,8 @@ func TestResolveReviewThread(t *testing.T) { // Setup client with mock client := githubv4.NewClient(tc.mockedClient) serverTool := PullRequestReviewWrite(translations.NullTranslationHelper) - if tc.withResolutionReason { - serverTool = PullRequestReviewWriteWithResolutionReason(translations.NullTranslationHelper) + if tc.ghes { + serverTool = PullRequestReviewWrite(translations.NullTranslationHelper, WithHost(utils.HostTypeGHES)) } deps := BaseDeps{ GQLClient: client, diff --git a/pkg/github/tools.go b/pkg/github/tools.go index 47189398b8..d616db99b5 100644 --- a/pkg/github/tools.go +++ b/pkg/github/tools.go @@ -215,7 +215,6 @@ func newToolConfig(opts []ToolOption) toolConfig { // AllTools returns all tools with their embedded toolset metadata. // Tool functions return ServerTool directly with toolset info. func AllTools(t translations.TranslationHelperFunc, opts ...ToolOption) []inventory.ServerTool { - cfg := newToolConfig(opts) return withCSVOutput([]inventory.ServerTool{ // Context tools GetMe(t), @@ -287,8 +286,7 @@ func AllTools(t translations.TranslationHelperFunc, opts ...ToolOption) []invent UpdatePullRequestBranch(t), CreatePullRequest(t), UpdatePullRequest(t), - pullRequestReviewWrite(t, false, cfg), - PullRequestReviewWriteWithResolutionReason(t, opts...), + PullRequestReviewWrite(t, opts...), AddCommentToPendingReview(t), AddReplyToPullRequestComment(t), @@ -391,8 +389,7 @@ func AllTools(t translations.TranslationHelperFunc, opts ...ToolOption) []invent GranularSubmitPendingPullRequestReview(t), GranularDeletePendingPullRequestReview(t), GranularAddPullRequestReviewComment(t), - granularResolveReviewThread(t, false, cfg), - GranularResolveReviewThreadWithResolutionReason(t, opts...), + GranularResolveReviewThread(t, opts...), GranularUnresolveReviewThread(t), GranularAddPullRequestReviewCommentReaction(t), GranularRemovePullRequestReviewCommentReaction(t), diff --git a/pkg/github/typed_consolidated_pull_request_outputs_test.go b/pkg/github/typed_consolidated_pull_request_outputs_test.go index 60afd2f1f1..8689726211 100644 --- a/pkg/github/typed_consolidated_pull_request_outputs_test.go +++ b/pkg/github/typed_consolidated_pull_request_outputs_test.go @@ -6,12 +6,10 @@ import ( "maps" "net/http" "reflect" - "slices" "strings" "testing" "time" - "github.com/github/github-mcp-server/v2/internal/toolsnaps" ghcontext "github.com/github/github-mcp-server/v2/pkg/context" "github.com/github/github-mcp-server/v2/pkg/inventory" "github.com/github/github-mcp-server/v2/pkg/translations" @@ -24,29 +22,20 @@ import ( var typedPullRequestProtocols = []string{inventory.ProtocolVersionMultiRoundTrip, "2025-11-25", ""} -func consolidatedPullRequestSession(t *testing.T, deps BaseDeps, protocol string, ui bool, flags ...inventory.FeatureFlag) (*mcp.ClientSession, map[string]*jsonschema.Resolved) { +func consolidatedPullRequestSession(t *testing.T, deps BaseDeps, protocol string, ui bool) (*mcp.ClientSession, map[string]*jsonschema.Resolved) { t.Helper() tr := translations.NullTranslationHelper tools := []inventory.ServerTool{ PullRequestRead(tr), CreatePullRequest(tr), UpdatePullRequest(tr), MergePullRequest(tr), - UpdatePullRequestBranch(tr), PullRequestReviewWrite(tr), PullRequestReviewWriteWithResolutionReason(tr), + UpdatePullRequestBranch(tr), PullRequestReviewWrite(tr), AddCommentToPendingReview(tr), AddReplyToPullRequestComment(tr), } canonicalSchemas := make(map[string]string) for _, tool := range tools { - if tool.Tool.Name == "pull_request_review_write" { - continue - } canonicalSchemas[tool.Tool.Name] = mustMarshalJSON(t, tool.Tool.OutputSchema) } - review := PullRequestReviewWrite(tr) - if slices.Contains(flags, FeatureFlagThreadResolutionReason) { - review = PullRequestReviewWriteWithResolutionReason(tr) - require.NoError(t, toolsnaps.Test("pull_request_review_write_resolution_reason", review.Tool)) - } - canonicalSchemas[review.Tool.Name] = mustMarshalJSON(t, review.Tool.OutputSchema) inv, err := inventory.NewBuilder().SetTools(tools).WithToolsets([]string{"all"}). - WithFeatureChecker(featureCheckerFor(flags...)).Build() + WithFeatureChecker(featureCheckerFor()).Build() require.NoError(t, err) server := mcp.NewServer(&mcp.Implementation{Name: "consolidated-pull-requests", Version: "v1"}, nil) server.AddReceivingMiddleware(InjectDepsMiddleware(deps)) @@ -85,8 +74,7 @@ func consolidatedPullRequestSession(t *testing.T, deps BaseDeps, protocol string session := connectCommentVisibilityClient(t, server, version) list, err := session.ListTools(context.Background(), nil) require.NoError(t, err) - // Exactly one pull_request_review_write variant is exposed for a feature set. - require.Len(t, list.Tools, len(tools)-1) + require.Len(t, list.Tools, len(tools)) schemas := make(map[string]*jsonschema.Resolved) for _, tool := range list.Tools { if protocol != inventory.ProtocolVersionMultiRoundTrip { @@ -355,7 +343,7 @@ func TestTypedPullRequestFilesLinkPagination(t *testing.T) { func TestTypedPullRequestReviewWriteResolutionReasonVariant(t *testing.T) { for _, protocol := range typedPullRequestProtocols { t.Run("protocol="+protocol, func(t *testing.T) { - session, schemas := consolidatedPullRequestSession(t, consolidatedPullRequestDeps(t), protocol, false, FeatureFlagThreadResolutionReason) + session, schemas := consolidatedPullRequestSession(t, consolidatedPullRequestDeps(t), protocol, false) list, err := session.ListTools(context.Background(), nil) require.NoError(t, err) for _, tool := range list.Tools { diff --git a/pkg/github/typed_granular_pull_request_outputs_test.go b/pkg/github/typed_granular_pull_request_outputs_test.go index 9585e96632..254a605df6 100644 --- a/pkg/github/typed_granular_pull_request_outputs_test.go +++ b/pkg/github/typed_granular_pull_request_outputs_test.go @@ -22,17 +22,16 @@ import ( "github.com/stretchr/testify/require" ) -func granularPullRequestTools() []inventory.ServerTool { +func granularPullRequestTools(opts ...ToolOption) []inventory.ServerTool { t := translations.NullTranslationHelper return []inventory.ServerTool{ GranularUpdatePullRequestTitle(t), GranularUpdatePullRequestBody(t), GranularUpdatePullRequestState(t), GranularUpdatePullRequestDraftState(t), GranularRequestPullRequestReviewers(t), GranularCreatePullRequestReview(t), GranularSubmitPendingPullRequestReview(t), GranularDeletePendingPullRequestReview(t), - GranularAddPullRequestReviewComment(t), GranularResolveReviewThread(t), + GranularAddPullRequestReviewComment(t), GranularResolveReviewThread(t, opts...), GranularUnresolveReviewThread(t), GranularAddPullRequestReviewCommentReaction(t), GranularRemovePullRequestReviewCommentReaction(t), - GranularResolveReviewThreadWithResolutionReason(t), } } @@ -186,13 +185,13 @@ func granularPRDeps(t *testing.T, current **granularPRCase, outcome string) Base func granularPRSession(t *testing.T, deps ToolDependencies, protocol string, reason bool) (*mcp.ClientSession, map[string]*jsonschema.Resolved) { t.Helper() - tools := granularPullRequestTools() - flags := []inventory.FeatureFlag{inventory.FeatureFlag(FeatureFlagPullRequestsGranular)} - if reason { - flags = append(flags, FeatureFlagThreadResolutionReason) + var opts []ToolOption + if !reason { + opts = append(opts, WithHost(utils.HostTypeGHES)) } + tools := granularPullRequestTools(opts...) inv, err := inventory.NewBuilder().SetTools(tools).WithToolsets([]string{"all"}). - WithFeatureChecker(featureCheckerFor(flags...)).Build() + WithFeatureChecker(featureCheckerFor(inventory.FeatureFlag(FeatureFlagPullRequestsGranular))).Build() require.NoError(t, err) server := mcp.NewServer(&mcp.Implementation{Name: "granular-pr", Version: "v1"}, nil) server.AddReceivingMiddleware(InjectDepsMiddleware(deps)) @@ -221,9 +220,6 @@ func granularPRSession(t *testing.T, deps ToolDependencies, protocol string, rea schemas := make(map[string]*jsonschema.Resolved) for _, tool := range list.Tools { name := tool.Name - if name == "resolve_review_thread" && reason { - name += "_resolution_reason" - } // Resolve the advertised input schema as well as every modern output. var inputSchema jsonschema.Schema require.NoError(t, json.Unmarshal([]byte(mustMarshalJSON(t, tool.InputSchema)), &inputSchema)) @@ -234,7 +230,9 @@ func granularPRSession(t *testing.T, deps ToolDependencies, protocol string, rea continue } require.NotNil(t, tool.OutputSchema, name) - require.NoError(t, toolsnaps.Test(name, *tool)) + if reason || name != "resolve_review_thread" { + require.NoError(t, toolsnaps.Test(name, *tool)) + } var schema jsonschema.Schema require.NoError(t, json.Unmarshal([]byte(mustMarshalJSON(t, tool.OutputSchema)), &schema)) resolved, err := schema.Resolve(nil) @@ -391,11 +389,8 @@ func TestGranularPullRequestFeatureVariants(t *testing.T) { assert.Equal(t, []string{"repo"}, tool.ScopeAccess.Scopes, tool.Tool.Name) assert.False(t, tool.FeatureRule.Enabled(func(inventory.FeatureFlag) bool { return false }), tool.Tool.Name) } - variant := GranularResolveReviewThreadWithResolutionReason(translations.NullTranslationHelper, WithHost(utils.HostTypeGHES)) - require.NotNil(t, variant.Enabled) - enabled, err := variant.Enabled(context.Background()) - require.NoError(t, err) - assert.False(t, enabled) + schema := GranularResolveReviewThread(translations.NullTranslationHelper, WithHost(utils.HostTypeGHES)).Tool.InputSchema.(*jsonschema.Schema) + assert.NotContains(t, schema.Properties, "resolutionReason") } func TestGranularPullRequestAdvertisedInputConstraints(t *testing.T) { @@ -487,9 +482,8 @@ func TestGranularPullRequestReactionSchema(t *testing.T) { } func TestGranularPullRequestParentBehavior(t *testing.T) { - tools := granularPullRequestTools() byName := make(map[string]inventory.ServerTool) - for _, tool := range tools[:len(tools)-1] { + for _, tool := range granularPullRequestTools() { byName[tool.Tool.Name] = tool } var current *granularPRCase From 979d92543781d6ffefe1163089ba358bfac3076c Mon Sep 17 00:00:00 2001 From: Annie Gesellchen <10727170+cagesellchen@users.noreply.github.com> Date: Fri, 6 Nov 2026 15:25:34 -0800 Subject: [PATCH 2/5] Send resolution reasons as GraphQL enum values The resolveReviewThread mutation expects ADDRESSED, WONT_FIX or INVALID, but the tools forwarded the lowercase input values unchanged. Map them to enum names and treat an empty reason as none. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- pkg/github/granular_tools_test.go | 2 +- pkg/github/pullrequests.go | 8 +++++--- pkg/github/pullrequests_test.go | 2 +- pkg/github/typed_granular_pull_request_outputs_test.go | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/github/granular_tools_test.go b/pkg/github/granular_tools_test.go index 90888ab035..995860d8ef 100644 --- a/pkg/github/granular_tools_test.go +++ b/pkg/github/granular_tools_test.go @@ -1720,7 +1720,7 @@ func TestGranularResolveReviewThread(t *testing.T) { { name: "forwards resolution reason", resolutionReason: new("addressed"), - expectedReason: new("addressed"), + expectedReason: new("ADDRESSED"), }, {name: "GHES omits resolution reason", ghes: true, resolutionReason: new("addressed")}, {name: "without resolution reason"}, diff --git a/pkg/github/pullrequests.go b/pkg/github/pullrequests.go index bfe10bb307..5f49c35a24 100644 --- a/pkg/github/pullrequests.go +++ b/pkg/github/pullrequests.go @@ -7,6 +7,7 @@ import ( "io" "net/http" "slices" + "strings" "github.com/go-viper/mapstructure/v2" "github.com/google/go-github/v92/github" @@ -2257,9 +2258,10 @@ func ResolveReviewThreadWithReason(ctx context.Context, client *githubv4.Client, } `graphql:"resolveReviewThread(input: $input)"` } - input := ResolveReviewThreadInput{ - ThreadID: githubv4.ID(threadID), - ResolutionReason: newGQLStringlikePtr[githubv4.String](resolutionReason), + input := ResolveReviewThreadInput{ThreadID: githubv4.ID(threadID)} + if resolutionReason != nil && *resolutionReason != "" { + // GraphQL expects enum names, e.g. "wont-fix" becomes WONT_FIX. + input.ResolutionReason = githubv4.NewString(githubv4.String(strings.ToUpper(strings.ReplaceAll(*resolutionReason, "-", "_")))) } if err := client.Mutate(ctx, &mutation, input, nil); err != nil { diff --git a/pkg/github/pullrequests_test.go b/pkg/github/pullrequests_test.go index c85ecf2c65..2241598eda 100644 --- a/pkg/github/pullrequests_test.go +++ b/pkg/github/pullrequests_test.go @@ -4824,7 +4824,7 @@ func TestResolveReviewThread(t *testing.T) { }{}, ResolveReviewThreadInput{ ThreadID: githubv4.ID("PRRT_kwDOTest123"), - ResolutionReason: newGQLStringlike[githubv4.String]("wont-fix"), + ResolutionReason: newGQLStringlike[githubv4.String]("WONT_FIX"), }, nil, githubv4mock.DataResponse(map[string]any{ diff --git a/pkg/github/typed_granular_pull_request_outputs_test.go b/pkg/github/typed_granular_pull_request_outputs_test.go index 254a605df6..ab27909cf5 100644 --- a/pkg/github/typed_granular_pull_request_outputs_test.go +++ b/pkg/github/typed_granular_pull_request_outputs_test.go @@ -533,7 +533,7 @@ func TestTypedGranularPullRequestClientErrors(t *testing.T) { func TestTypedGranularPullRequestResolutionReasonPayload(t *testing.T) { for _, protocol := range typedPullRequestProtocols { for _, reason := range []bool{false, true} { - for _, value := range []string{"addressed", "wont-fix", "invalid", ""} { + for value, want := range map[string]string{"addressed": "ADDRESSED", "wont-fix": "WONT_FIX", "invalid": "INVALID", "": ""} { client := &http.Client{Transport: recorderTransport{handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var request struct { Variables struct { @@ -545,9 +545,9 @@ func TestTypedGranularPullRequestResolutionReasonPayload(t *testing.T) { } require.NoError(t, json.NewDecoder(r.Body).Decode(&request)) assert.Equal(t, "T_1", request.Variables.Input.ThreadID) - if reason { + if reason && want != "" { require.NotNil(t, request.Variables.Input.ResolutionReason) - assert.Equal(t, value, *request.Variables.Input.ResolutionReason) + assert.Equal(t, want, *request.Variables.Input.ResolutionReason) } else { assert.Nil(t, request.Variables.Input.ResolutionReason) } From 440cbffeaed502fa96f6e52c19bc9bef2d43ec50 Mon Sep 17 00:00:00 2001 From: Annie Gesellchen <10727170+cagesellchen@users.noreply.github.com> Date: Mon, 9 Nov 2026 10:56:02 -0800 Subject: [PATCH 3/5] Remove stale resolution-reason variant comment Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- pkg/github/consolidated_pull_request_types.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/github/consolidated_pull_request_types.go b/pkg/github/consolidated_pull_request_types.go index 6d6abaed63..d2059dca70 100644 --- a/pkg/github/consolidated_pull_request_types.go +++ b/pkg/github/consolidated_pull_request_types.go @@ -69,8 +69,6 @@ type UpdatePullRequestBranchInput struct { ExpectedHeadSHA *string `json:"expectedHeadSha,omitempty"` } -// PullRequestReviewWriteInput covers both feature variants; resolutionReason -// is advertised and used only by the resolution-reason variant. type PullRequestReviewWriteInput struct { Method string `json:"method"` Owner string `json:"owner"` From 8f7811f2d4aefd2e4921a886b93621d7177ef9e6 Mon Sep 17 00:00:00 2001 From: Annie Gesellchen <10727170+cagesellchen@users.noreply.github.com> Date: Tue, 10 Nov 2026 10:33:12 -0800 Subject: [PATCH 4/5] Drop unrelated comment and test-name changes Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- pkg/github/consolidated_pull_request_types.go | 2 ++ pkg/github/feature_flags_test.go | 8 ++++---- pkg/github/granular_tools_test.go | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/github/consolidated_pull_request_types.go b/pkg/github/consolidated_pull_request_types.go index d2059dca70..6d6abaed63 100644 --- a/pkg/github/consolidated_pull_request_types.go +++ b/pkg/github/consolidated_pull_request_types.go @@ -69,6 +69,8 @@ type UpdatePullRequestBranchInput struct { ExpectedHeadSHA *string `json:"expectedHeadSha,omitempty"` } +// PullRequestReviewWriteInput covers both feature variants; resolutionReason +// is advertised and used only by the resolution-reason variant. type PullRequestReviewWriteInput struct { Method string `json:"method"` Owner string `json:"owner"` diff --git a/pkg/github/feature_flags_test.go b/pkg/github/feature_flags_test.go index bc2ffb710d..b0100a6c60 100644 --- a/pkg/github/feature_flags_test.go +++ b/pkg/github/feature_flags_test.go @@ -238,23 +238,23 @@ func TestThreadResolutionReasonToolVariants(t *testing.T) { hasReason bool }{ { - name: "consolidated", + name: "consolidated flag on", toolName: "pull_request_review_write", hasReason: true, }, { - name: "granular", + name: "granular flag on", flags: []inventory.FeatureFlag{inventory.FeatureFlag(FeatureFlagPullRequestsGranular)}, toolName: "resolve_review_thread", hasReason: true, }, { - name: "consolidated GHES", + name: "consolidated flag on GHES", host: utils.HostTypeGHES, toolName: "pull_request_review_write", }, { - name: "granular GHES", + name: "granular flag on GHES", flags: []inventory.FeatureFlag{inventory.FeatureFlag(FeatureFlagPullRequestsGranular)}, host: utils.HostTypeGHES, toolName: "resolve_review_thread", diff --git a/pkg/github/granular_tools_test.go b/pkg/github/granular_tools_test.go index 995860d8ef..b63485fe9d 100644 --- a/pkg/github/granular_tools_test.go +++ b/pkg/github/granular_tools_test.go @@ -1718,7 +1718,7 @@ func TestGranularResolveReviewThread(t *testing.T) { expectedReason *string }{ { - name: "forwards resolution reason", + name: "enabled variant forwards resolution reason", resolutionReason: new("addressed"), expectedReason: new("ADDRESSED"), }, From 28688c1a291d0986c1010dbbe0faf5428eab64db Mon Sep 17 00:00:00 2001 From: Annie Gesellchen <10727170+cagesellchen@users.noreply.github.com> Date: Thu, 12 Nov 2026 11:58:48 -0800 Subject: [PATCH 5/5] Advertise resolution reasons as a schema enum Empty reasons are still accepted and treated as none. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- pkg/github/__toolsnaps__/pull_request_review_write.snap | 5 +++++ pkg/github/__toolsnaps__/resolve_review_thread.snap | 5 +++++ pkg/github/consolidated_pull_request_types.go | 4 ++-- pkg/github/granular_pull_request_types.go | 6 +++++- pkg/github/pullrequests.go | 1 + pkg/github/pullrequests_granular.go | 1 + pkg/github/typed_consolidated_pull_request_outputs_test.go | 2 +- 7 files changed, 20 insertions(+), 4 deletions(-) diff --git a/pkg/github/__toolsnaps__/pull_request_review_write.snap b/pkg/github/__toolsnaps__/pull_request_review_write.snap index 45e19ca7bf..260bddd117 100644 --- a/pkg/github/__toolsnaps__/pull_request_review_write.snap +++ b/pkg/github/__toolsnaps__/pull_request_review_write.snap @@ -49,6 +49,11 @@ }, "resolutionReason": { "description": "Optional reason for resolving a Copilot code review thread: addressed, wont-fix, or invalid.", + "enum": [ + "addressed", + "wont-fix", + "invalid" + ], "type": "string" }, "threadId": { diff --git a/pkg/github/__toolsnaps__/resolve_review_thread.snap b/pkg/github/__toolsnaps__/resolve_review_thread.snap index b8bf2c8c7d..0eeaa7d659 100644 --- a/pkg/github/__toolsnaps__/resolve_review_thread.snap +++ b/pkg/github/__toolsnaps__/resolve_review_thread.snap @@ -23,6 +23,11 @@ "properties": { "resolutionReason": { "description": "Optional reason for resolving a Copilot code review thread: addressed, wont-fix, or invalid.", + "enum": [ + "addressed", + "wont-fix", + "invalid" + ], "type": "string" }, "threadID": { diff --git a/pkg/github/consolidated_pull_request_types.go b/pkg/github/consolidated_pull_request_types.go index 6d6abaed63..fbe8c1102a 100644 --- a/pkg/github/consolidated_pull_request_types.go +++ b/pkg/github/consolidated_pull_request_types.go @@ -598,7 +598,7 @@ func normalizePullRequestReviewWriteArguments(raw json.RawMessage) (json.RawMess "method": params.Method, "owner": params.Owner, "repo": params.Repo, "pullNumber": params.PullNumber, } // Empty optional strings are equivalent to omitted ones for the handler, - // but would fail the schema's enum for event. + // but would fail the schema's enums for event and resolutionReason. for key, value := range map[string]string{"body": params.Body, "event": params.Event, "threadId": params.ThreadID} { if value != "" { canonical[key] = value @@ -607,7 +607,7 @@ func normalizePullRequestReviewWriteArguments(raw json.RawMessage) (json.RawMess if params.CommitID != nil { canonical["commitID"] = *params.CommitID } - if params.ResolutionReason != nil { + if params.ResolutionReason != nil && *params.ResolutionReason != "" { canonical["resolutionReason"] = *params.ResolutionReason } for key := range args { diff --git a/pkg/github/granular_pull_request_types.go b/pkg/github/granular_pull_request_types.go index 6a173e13a4..248d571f47 100644 --- a/pkg/github/granular_pull_request_types.go +++ b/pkg/github/granular_pull_request_types.go @@ -208,7 +208,11 @@ func normalizeGranularPullRequestFields(args map[string]any, kind string) error return err } if kind == "resolve_reason" { - _, _, err := OptionalParamOK[string](args, "resolutionReason") + reason, _, err := OptionalParamOK[string](args, "resolutionReason") + if reason == "" { + // An empty reason means none and would fail the schema's enum. + delete(args, "resolutionReason") + } return err } delete(args, "resolutionReason") diff --git a/pkg/github/pullrequests.go b/pkg/github/pullrequests.go index 5f49c35a24..7f9e337d38 100644 --- a/pkg/github/pullrequests.go +++ b/pkg/github/pullrequests.go @@ -2034,6 +2034,7 @@ func PullRequestReviewWrite(t translations.TranslationHelperFunc, opts ...ToolOp schema.Properties["resolutionReason"] = &jsonschema.Schema{ Type: "string", Description: "Optional reason for resolving a Copilot code review thread: addressed, wont-fix, or invalid.", + Enum: []any{"addressed", "wont-fix", "invalid"}, } } diff --git a/pkg/github/pullrequests_granular.go b/pkg/github/pullrequests_granular.go index 2c8713c91e..e8782d998d 100644 --- a/pkg/github/pullrequests_granular.go +++ b/pkg/github/pullrequests_granular.go @@ -590,6 +590,7 @@ func GranularResolveReviewThread(t translations.TranslationHelperFunc, opts ...T properties["resolutionReason"] = &jsonschema.Schema{ Type: "string", Description: "Optional reason for resolving a Copilot code review thread: addressed, wont-fix, or invalid.", + Enum: []any{"addressed", "wont-fix", "invalid"}, } } diff --git a/pkg/github/typed_consolidated_pull_request_outputs_test.go b/pkg/github/typed_consolidated_pull_request_outputs_test.go index 8689726211..4c0a76aa8f 100644 --- a/pkg/github/typed_consolidated_pull_request_outputs_test.go +++ b/pkg/github/typed_consolidated_pull_request_outputs_test.go @@ -352,7 +352,7 @@ func TestTypedPullRequestReviewWriteResolutionReasonVariant(t *testing.T) { } } runTypedPullRequestCases(t, session, schemas, []typedPullRequestCase{ - {"pull_request_review_write", map[string]any{"Method": "resolve_thread", "ThreadID": "T_1", "resolutionReason": "OUTDATED"}, "review thread resolved successfully"}, + {"pull_request_review_write", map[string]any{"Method": "resolve_thread", "ThreadID": "T_1", "resolutionReason": "invalid"}, "review thread resolved successfully"}, {"pull_request_review_write", map[string]any{"method": "create", "pullNumber": 1.5}, "pending pull request created"}, }) })