Skip to content

Commit 8bbf01e

Browse files
committed
fix: correct parameter parsing in MarkPullRequestReadyForReview function
- Replace incorrect request.Params.GetString/GetInt calls with requiredParam/RequiredInt - Fix undefined params struct reference in GraphQL variables map - Use local variables (owner, repo, pullNumber) instead of non-existent params fields - Standardize error reporting to match project conventions Fixes compilation errors and ensures consistent parameter handling across the codebase.
1 parent 9d7e9a7 commit 8bbf01e

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

pkg/github/pullrequests.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,20 +1630,19 @@ func MarkPullRequestReadyForReview(getGQLClient GetGQLClientFn, t translations.T
16301630
),
16311631
),
16321632
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
1633-
owner, err := request.Params.GetString("owner")
1633+
owner, err := requiredParam[string](request, "owner")
16341634
if err != nil {
1635-
return mcp.NewToolResultError(fmt.Sprintf("Invalid or missing 'owner': %v", err)), nil
1635+
return mcp.NewToolResultError(err.Error()), nil
16361636
}
1637-
1638-
repo, err := request.Params.GetString("repo")
1637+
repo, err := requiredParam[string](request, "repo")
16391638
if err != nil {
1640-
return mcp.NewToolResultError(fmt.Sprintf("Invalid or missing 'repo': %v", err)), nil
1639+
return mcp.NewToolResultError(err.Error()), nil
16411640
}
1642-
1643-
pullNumber, err := request.Params.GetInt("pullNumber")
1641+
pullNumber, err := RequiredInt(request, "pullNumber")
16441642
if err != nil {
1645-
return mcp.NewToolResultError(fmt.Sprintf("Invalid or missing 'pullNumber': %v", err)), nil
1643+
return mcp.NewToolResultError(err.Error()), nil
16461644
}
1645+
16471646
// Get the GraphQL client
16481647
client, err := getGQLClient(ctx)
16491648
if err != nil {
@@ -1661,9 +1660,9 @@ func MarkPullRequestReadyForReview(getGQLClient GetGQLClientFn, t translations.T
16611660
}
16621661

16631662
variables := map[string]any{
1664-
"owner": githubv4.String(params.Owner),
1665-
"repo": githubv4.String(params.Repo),
1666-
"prNum": githubv4.Int(params.PullNumber),
1663+
"owner": githubv4.String(owner),
1664+
"repo": githubv4.String(repo),
1665+
"prNum": githubv4.Int(pullNumber),
16671666
}
16681667

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

0 commit comments

Comments
 (0)