Skip to content

Commit 596ce58

Browse files
authored
Use constant for limit
1 parent 230ca60 commit 596ce58

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

pkg/github/issues.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,7 @@ const (
13581358
// DefaultClosingPRsLimit is the default number of closing PRs to return per issue
13591359
// Aligned with GitHub GraphQL API default of 100 items per page
13601360
DefaultClosingPRsLimit = 100
1361+
MaxGraphQLPageSize = 250 // Maximum page size for GitHub GraphQL API
13611362
)
13621363

13631364
// FindClosingPullRequests creates a tool to find pull requests that closed specific issues
@@ -1386,7 +1387,11 @@ func FindClosingPullRequests(getGQLClient GetGQLClientFn, t translations.Transla
13861387
),
13871388
),
13881389
mcp.WithNumber("limit",
1389-
mcp.Description("Maximum number of closing PRs to return per issue (default: 100, max: 250)"),
1390+
mcp.Description(fmt.Sprintf(
1391+
"Maximum number of closing PRs to return per issue (default: %d, max: %d)",
1392+
DefaultClosingPRsLimit,
1393+
MaxGraphQLPageSize,
1394+
)),
13901395
),
13911396
mcp.WithBoolean("includeClosedPrs",
13921397
mcp.Description("Include closed/merged pull requests in results (default: false)"),
@@ -1404,7 +1409,10 @@ func FindClosingPullRequests(getGQLClient GetGQLClientFn, t translations.Transla
14041409
mcp.Description("Cursor for backward pagination (use with last)"),
14051410
),
14061411
mcp.WithNumber("last",
1407-
mcp.Description("Number of results from end for backward pagination (max: 250)"),
1412+
mcp.Description(fmt.Sprintf(
1413+
"Number of results from end for backward pagination (max: %d)",
1414+
MaxGraphQLPageSize,
1415+
)),
14081416
),
14091417
),
14101418
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
@@ -1415,11 +1423,11 @@ func FindClosingPullRequests(getGQLClient GetGQLClientFn, t translations.Transla
14151423
limitExplicitlySet = true
14161424
if limitFloat, ok := limitParam.(float64); ok {
14171425
limit = int(limitFloat)
1418-
if limit <= 0 || limit > 250 {
1419-
return mcp.NewToolResultError("limit must be between 1 and 250 inclusive (GitHub GraphQL API maximum)"), nil
1426+
if limit <= 0 || limit > MaxGraphQLPageSize {
1427+
return mcp.NewToolResultError(fmt.Sprintf("limit must be between 1 and %d inclusive (GitHub GraphQL API maximum)", MaxGraphQLPageSize)), nil
14201428
}
14211429
} else {
1422-
return mcp.NewToolResultError("limit must be a number between 1 and 250 (GitHub GraphQL API maximum)"), nil
1430+
return mcp.NewToolResultError(fmt.Sprintf("limit must be a number between 1 and %d (GitHub GraphQL API maximum)", MaxGraphQLPageSize)), nil
14231431
}
14241432
}
14251433

@@ -1428,8 +1436,8 @@ func FindClosingPullRequests(getGQLClient GetGQLClientFn, t translations.Transla
14281436
if err != nil {
14291437
return mcp.NewToolResultError(fmt.Sprintf("last parameter error: %s", err.Error())), nil
14301438
}
1431-
if last != 0 && (last <= 0 || last > 250) {
1432-
return mcp.NewToolResultError("last must be between 1 and 250 inclusive for backward pagination (GitHub GraphQL API maximum)"), nil
1439+
if last != 0 && (last <= 0 || last > MaxGraphQLPageSize) {
1440+
return mcp.NewToolResultError(fmt.Sprintf("last must be between 1 and %d inclusive for backward pagination (GitHub GraphQL API maximum)", MaxGraphQLPageSize)), nil
14331441
}
14341442

14351443
// Parse cursor parameters

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy