You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GHCommitPointer throws NPE on null repository #2035
I receive an NPE on GHCommitPointer#getCommit because getRepository() returns null.
I assume getRepository() should always be populated as I need a GHRepository to even get the initial PR/issue in the first place.
To Reproduce
While scanning https://github.com/checkstyle/checkstyle/pulls , I pick up PR 1.
I call GHPullRequest#getHead() and get the GHCommitPointer.
I call GHCommitPointer#getCommit() and receive an NPE. getRepository() returns null.
Expected behavior
No NPE.
Additional context
GHPullRequest#getBase() doesn't seem to have this issue.
getCommit() calls getRepository().getCommit(getSha()) with no null check. Jackson fills the pointer from the pull request JSON, and a head whose repo field is null leaves getRepository() null, so that call throws NullPointerException.
getCommit() now takes the repository and throws IOException with the message "Repository information is unavailable for this commit pointer" when it is null.
Activity
rnveach commentedon Feb 17, 2025
@bitwiseman Can you explain how
repois normally populated? I assume there is reflection going on here as there is no setter or assignment.github-api/src/main/java/org/kohsuke/github/GHCommitPointer.java
Line 46 in e14ec3b
bitwiseman commentedon Feb 24, 2025
@rnveach
https://github.com/FasterXML/jackson populating from JSON to objects.
mvanhorn commentedon Oct 22, 2026
getCommit() calls getRepository().getCommit(getSha()) with no null check. Jackson fills the pointer from the pull request JSON, and a head whose repo field is null leaves getRepository() null, so that call throws NullPointerException.
getCommit() now takes the repository and throws IOException with the message "Repository information is unavailable for this commit pointer" when it is null.
#2340
fix: resolve GHCommitPointer commit through the pull request repository