Skip to content

Commit 8977899

Browse files
authored
Fix lint issue
1 parent 13de1b9 commit 8977899

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

pkg/github/issues.go

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"fmt"
77
"io"
8+
"math"
89
"net/http"
910
"strings"
1011
"time"
@@ -1558,19 +1559,35 @@ func queryClosingPRsForIssueEnhanced(ctx context.Context, client *githubv4.Clien
15581559
} `graphql:"repository(owner: $owner, name: $repo)"`
15591560
}
15601561

1561-
// Build variables map with conditional inclusion
1562+
// Validate issue number
1563+
if issueNumber < 0 || issueNumber > math.MaxInt32 {
1564+
return nil, fmt.Errorf("issue number %d is out of valid range", issueNumber)
1565+
}
1566+
issueNumber32 := int32(issueNumber) // safe: range-checked above
1567+
1568+
// Validate pagination
1569+
if params.Last != 0 && (params.Last < 0 || params.Last > math.MaxInt32) {
1570+
return nil, fmt.Errorf("last parameter %d is out of valid range", params.Last)
1571+
}
1572+
if params.First < 0 || params.First > math.MaxInt32 {
1573+
return nil, fmt.Errorf("first parameter %d is out of valid range", params.First)
1574+
}
1575+
1576+
first32 := int32(params.First)
1577+
last32 := int32(params.Last)
1578+
1579+
// Build variables map
15621580
variables := map[string]any{
15631581
"owner": githubv4.String(owner),
15641582
"repo": githubv4.String(repo),
1565-
"number": githubv4.Int(issueNumber),
1583+
"number": githubv4.Int(issueNumber32),
15661584
}
15671585

1568-
// Add pagination parameters conditionally
1569-
if params.Last != 0 {
1570-
variables["last"] = githubv4.Int(params.Last)
1586+
if last32 != 0 {
1587+
variables["last"] = githubv4.Int(last32)
15711588
variables["first"] = (*githubv4.Int)(nil)
15721589
} else {
1573-
variables["first"] = githubv4.Int(params.First)
1590+
variables["first"] = githubv4.Int(first32)
15741591
variables["last"] = (*githubv4.Int)(nil)
15751592
}
15761593

0 commit comments

Comments
 (0)