Skip to content

Commit 2461623

Browse files
committed
Make MarkPullRequestReadyForReview consistent with other GraphQL functions
- Replace RequiredInt + manual conversion with mapstructure.Decode pattern - Use int32 PullNumber field in params struct like other GraphQL functions - Eliminates integer overflow concerns and maintains consistency - Follows established pattern used by CreateAndSubmitPullRequestReview, etc.
1 parent ed57b69 commit 2461623

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

pkg/github/pullrequests.go

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,25 +1630,15 @@ func MarkPullRequestReadyForReview(getGQLClient GetGQLClientFn, t translations.T
16301630
),
16311631
),
16321632
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
1633-
owner, err := requiredParam[string](request, "owner")
1634-
if err != nil {
1635-
return mcp.NewToolResultError(err.Error()), nil
1636-
}
1637-
repo, err := requiredParam[string](request, "repo")
1638-
if err != nil {
1639-
return mcp.NewToolResultError(err.Error()), nil
1633+
var params struct {
1634+
Owner string
1635+
Repo string
1636+
PullNumber int32
16401637
}
1641-
pullNumber, err := RequiredInt(request, "pullNumber")
1642-
if err != nil {
1638+
if err := mapstructure.Decode(request.Params.Arguments, &params); err != nil {
16431639
return mcp.NewToolResultError(err.Error()), nil
16441640
}
16451641

1646-
// Convert int to int32 with bounds checking to avoid integer overflow
1647-
if pullNumber < 0 || pullNumber > 2147483647 {
1648-
return mcp.NewToolResultError("pullNumber out of range for int32"), nil
1649-
}
1650-
pullNumber32 := int32(pullNumber)
1651-
16521642
// Get the GraphQL client
16531643
client, err := getGQLClient(ctx)
16541644
if err != nil {
@@ -1666,9 +1656,9 @@ func MarkPullRequestReadyForReview(getGQLClient GetGQLClientFn, t translations.T
16661656
}
16671657

16681658
variables := map[string]any{
1669-
"owner": githubv4.String(owner),
1670-
"repo": githubv4.String(repo),
1671-
"prNum": githubv4.Int(pullNumber32),
1659+
"owner": githubv4.String(params.Owner),
1660+
"repo": githubv4.String(params.Repo),
1661+
"prNum": githubv4.Int(params.PullNumber),
16721662
}
16731663

16741664
if err := client.Query(ctx, &getPullRequestQuery, variables); err != nil {

0 commit comments

Comments
 (0)