Fix nil-pointer panic when GitHub returns a rate-limit error - #800
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request prevents a nil-pointer panic during datasource error-source classification by guarding access to go-github’s embedded *http.Response before reading StatusCode. This keeps request failures from being misclassified via an SDK panic path and aligns the classification behavior with the intended error handling flow.
Changes:
- Add a defensive check for
resp.Response != nilbefore readingresp.StatusCodeinaddErrorSourceToError. - Add a regression test covering the “non-nil wrapper
Responsewith nil inner*http.Response” scenario.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/github/client/errorsourcehandling.go | Avoids nil-pointer panic by guarding the embedded *http.Response before using StatusCode. |
| pkg/github/client/errorsourcehandling_test.go | Adds a test to ensure the nil inner *http.Response case does not panic and preserves the error. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
aangelisc
reviewed
Aug 18, 2026
aangelisc
reviewed
Aug 20, 2026
aangelisc
approved these changes
Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
sanitizeGitHubErrornow flattens all go-github error types with a customIsmethod (ErrorResponse,RateLimitError,AbuseRateLimitError,AcceptedError,RedirectionError) to a plain error, not justErrorResponse.Why
When GitHub rate-limits a query, go-github returns a
*RateLimitError, whoseIsmethod callserrors.As(target, &v). The SDK'sguessErrorStatusclassifies errors viaerrors.Is(err, (*url.Error)(nil))(a typed-nil target), which routes intoRateLimitError.Isand calls(*url.Error).Unwrapon a nil receiver, panicking. The panic is recovered as aplugin.requestFailureError, so it counts against theDatasourcePluginQuerySuccessRateSLO.sanitizeGitHubErroralready guarded against this but only forErrorResponse; all five types share the same unsafeIs. Flattening withfmt.Errorf("%s", ...)(not%w) drops theIsmethod while keeping the message, so downstream classification is unaffected.