Content-Length: 359816 | pFad | http://github.com/github/github-mcp-server/commit/b4549269e23ce9c827662978c9a8f49112c59e6e

C2 refactor pagination error handling · github/github-mcp-server@b454926 · GitHub
Skip to content

Commit b454926

Browse files
committed
refactor pagination error handling
1 parent 30e01f4 commit b454926

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

pkg/github/discussions.go

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ func ListDiscussions(getGQLClient GetGQLClientFn, t translations.TranslationHelp
5353
// Get pagination parameters and convert to GraphQL format
5454
unifiedPagination, err := OptionalUnifiedPaginationParams(request)
5555
if err != nil {
56-
return mcp.NewToolResultError(err.Error()), nil
56+
return nil, err
57+
}
58+
pagination, err := unifiedPagination.ToGraphQLParams()
59+
if err != nil {
60+
return nil, err
5761
}
58-
pagination := unifiedPagination.ToGraphQLParams()
5962

6063
client, err := getGQLClient(ctx)
6164
if err != nil {
@@ -276,15 +279,18 @@ func GetDiscussionComments(getGQLClient GetGQLClientFn, t translations.Translati
276279
// Get unified pagination parameters and convert to GraphQL format
277280
unifiedPagination, err := OptionalUnifiedPaginationParams(request)
278281
if err != nil {
279-
return mcp.NewToolResultError(err.Error()), nil
282+
return nil, err
280283
}
281284

282285
// Check if pagination parameters were explicitly provided
283-
_, pageProvided := request.Params.Arguments.(map[string]interface{})["page"]
284-
_, perPageProvided := request.Params.Arguments.(map[string]interface{})["perPage"]
286+
_, pageProvided := request.GetArguments()["page"]
287+
_, perPageProvided := request.GetArguments()["perPage"]
285288
paginationExplicit := pageProvided || perPageProvided
286289

287-
paginationParams := unifiedPagination.ToGraphQLParams()
290+
paginationParams, err := unifiedPagination.ToGraphQLParams()
291+
if err != nil {
292+
return nil, err
293+
}
288294

289295
// Use default of 100 if pagination was not explicitly provided
290296
if !paginationExplicit {
@@ -366,15 +372,18 @@ func ListDiscussionCategories(getGQLClient GetGQLClientFn, t translations.Transl
366372
// Get unified pagination parameters and convert to GraphQL format
367373
unifiedPagination, err := OptionalUnifiedPaginationParams(request)
368374
if err != nil {
369-
return mcp.NewToolResultError(err.Error()), nil
375+
return nil, err
370376
}
371377

372378
// Check if pagination parameters were explicitly provided
373-
_, pageProvided := request.Params.Arguments.(map[string]interface{})["page"]
374-
_, perPageProvided := request.Params.Arguments.(map[string]interface{})["perPage"]
379+
_, pageProvided := request.GetArguments()["page"]
380+
_, perPageProvided := request.GetArguments()["perPage"]
375381
paginationExplicit := pageProvided || perPageProvided
376382

377-
pagination := unifiedPagination.ToGraphQLParams()
383+
pagination, err := unifiedPagination.ToGraphQLParams()
384+
if err != nil {
385+
return nil, err
386+
}
378387

379388
// Use default of 100 if pagination was not explicitly provided
380389
if !paginationExplicit {

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/github/github-mcp-server/commit/b4549269e23ce9c827662978c9a8f49112c59e6e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy