-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Bug Description
fetchIssueIDs in pkg/github/issues.go discards the underlying GraphQL error at both call sites (lines 65 and 87), returning only a static string with zero diagnostic context.
Affected Code
File: pkg/github/issues.go, lines 64-66 and 86-88
// Line 64-66
if err := gqlClient.Query(ctx, &query, vars); err != nil {
return "", "", fmt.Errorf("failed to get issue ID") // err is dropped
}
// Line 86-88
if err := gqlClient.Query(ctx, &query, vars); err != nil {
return "", "", fmt.Errorf("failed to get issue ID") // err is dropped
}Both use fmt.Errorf("failed to get issue ID") with no %w verb and no reference to the captured err.
Impact
When CloseIssue (line ~1308) calls fetchIssueIDs and it fails, the caller's error message — "Failed to find issues" — cannot be supplemented with the actual root cause. Possible root causes that are silently swallowed:
- Authentication failure (expired token, insufficient scopes)
- Rate limiting (GraphQL secondary rate limits)
- Network error (DNS, timeout, TLS)
- Issue not found (wrong owner/repo, deleted issue)
All of these produce the same opaque error: failed to get issue ID.
Steps to Reproduce
- Call
CloseIssuewith a valid owner/repo but an issue number that doesn't exist - Or trigger a GraphQL rate limit
- Observe the error message contains no diagnostic information about why the query failed
Expected Behavior
Error should wrap the original cause:
return "", "", fmt.Errorf("failed to get issue ID: %w", err)Actual Behavior
Error is a static string with no root cause context.
Proposed Solution
Option A (recommended): Wrap the error with %w
// Both call sites:
if err := gqlClient.Query(ctx, &query, vars); err != nil {
return "", "", fmt.Errorf("failed to get issue ID: %w", err)
}Option B: Use the project's ghErrors package for consistency with REST error handling patterns used elsewhere in the codebase.
| Aspect | Option A | Option B |
|---|---|---|
| Complexity | One-line change per site | Requires new ghErrors helper for GraphQL |
| Breaking changes | None | None |
| Consistency | Follows Go stdlib convention | Follows project's error-reporting pattern |
Happy to submit a PR for this fix.