Skip to content

Comments

Sanitize go-github ErrorResponse to prevent panic in SDK error handling#629

Merged
itsmylife merged 5 commits intomainfrom
ismail/fix-panic
Feb 12, 2026
Merged

Sanitize go-github ErrorResponse to prevent panic in SDK error handling#629
itsmylife merged 5 commits intomainfrom
ismail/fix-panic

Conversation

@itsmylife
Copy link
Contributor

@itsmylife itsmylife commented Feb 12, 2026

Summary

Fixes a nil pointer dereference panic caused by the interaction between go-github v81's
ErrorResponse.Is and the SDK's guessErrorStatus function.

go-github v76 (bumped from v72 to v81 in #574) changed ErrorResponse.Is from a simple type assertion
to calling errors.As(target, &v) on the target. See PR: google/go-github#3739
The SDK's guessErrorStatus
(backend/status.go:112) passes typed nil targets ((*url.Error)(nil)) to errors.Is.
When errors.Is walks the error chain and reaches *github.ErrorResponse, the v81
ErrorResponse.Is calls errors.As on that typed nil, which tries to call Unwrap() on
the nil receiver — causing a nil pointer dereference panic.

The fix adds sanitizeGitHubError which converts *github.ErrorResponse to a plain error
at the addErrorSourceToError boundary, preserving the error message while stripping the
problematic Is method from the error chain.

Manual reproduction steps

  1. Run Grafana with the github-datasource plugin (v2.5.0)
  2. Configure the GitHub datasource with a valid personal access token
  3. Open Explore (or create a panel) and select the GitHub datasource
  4. Set query type to Workflows (or Code Scanning)
  5. Set Owner to grafana, Repository to this-repo-does-not-exist
  6. Run the query
  7. Observe the panic in Grafana server logs:
    panic triggered error="runtime error: invalid memory address or nil pointer dereference"

With this fix applied, the query returns a proper error response instead of panicking.

Fixes https://github.com/grafana/oss-big-tent-squad/issues/183

@itsmylife itsmylife requested a review from a team as a code owner February 12, 2026 12:00
@itsmylife itsmylife requested review from itsgareth and removed request for a team February 12, 2026 12:00
@github-project-automation github-project-automation bot moved this to Backlog in OSS Big Tent Feb 12, 2026
@itsmylife itsmylife requested a review from zoltanbedi February 12, 2026 12:02
Copy link
Member

@zoltanbedi zoltanbedi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@itsmylife itsmylife merged commit afcc6d6 into main Feb 12, 2026
20 checks passed
@itsmylife itsmylife deleted the ismail/fix-panic branch February 12, 2026 12:46
@github-project-automation github-project-automation bot moved this from Backlog to Complete in OSS Big Tent Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

2 participants