Skip to content

Commit 30e01f4

Browse files
committed
add error handling for perPage value in ToGraphQLParams
1 parent f701670 commit 30e01f4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pkg/github/server.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,14 @@ type UnifiedPaginationParams struct {
245245

246246
// ToGraphQLParams converts REST API pagination parameters to GraphQL-specific parameters.
247247
// This converts page/perPage to first parameter for GraphQL queries.
248-
func (u UnifiedPaginationParams) ToGraphQLParams() GraphQLPaginationParams {
248+
func (u UnifiedPaginationParams) ToGraphQLParams() (GraphQLPaginationParams, error) {
249+
if u.PerPage > 100 {
250+
return GraphQLPaginationParams{}, fmt.Errorf("perPage value %d exceeds maximum of 100", u.PerPage)
251+
}
249252
first := int32(u.PerPage)
250253
return GraphQLPaginationParams{
251-
First: &first, //nolint:gosec // G115: This is safe, we cap perPage to 100 in the toolset
252-
}
254+
First: &first,
255+
}, nil
253256
}
254257

255258
// OptionalUnifiedPaginationParams returns pagination parameters from the request.

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