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
new GitHubBuilder()
.withJwtToken("token")
.build()
.getApp()
.getInstallationById(githubInstallationId)
.getAccount()
.getType()
leads to 401:
Caused by: org.kohsuke.github.HttpException: {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest"}
at org.kohsuke.github.GitHubConnectorResponseErrorHandler$1.onError(GitHubConnectorResponseErrorHandler.java:62) ~[github-api-unbridged-1.318.jar:na]
There are a few issues here:
The field is already initialized as "Organization" after calling getAccount(), so populating here is not necessary, perhaps.
installation.getAccount().getUrl() returns https://api.github.com/users/<ORGANIZATION_LOGIN>, which perhaps is invalid, because it's an organization, not a user.
Unfortunately, I couldn't find a way to work around this by determining installation owner's account type, please let me know if there's something I missed
@bitwiseman got it. How should we solve this taking into consideration the fact that there are multiple fields like this? Should we track the "populated = true/false" flag for an entity or something else?
@Haarolean
In this specific case, you can guard the populate() call with if (type == null).
I think some of the classes have a populate(bool doPopulate) method or populate(Object objectToCheckForNullValue) to streamline this process.
Tracking bool isPopulated; as field could also work.
I don't like the way we currently don't know what fields we have actually loaded in an instance, but I haven't had time to ponder a better solution for the range partial fields that are returned. Maybe have the base record and then use interfaces to show what fields are present.
Activity
Haarolean commentedon Mar 14, 2024
Unfortunately, I couldn't find a way to work around this by determining installation owner's account type, please let me know if there's something I missed
UPD: Found a workaround:
bitwiseman commentedon Mar 15, 2024
Here's the problem:
github-api/src/main/java/org/kohsuke/github/GHPerson.java
Lines 342 to 344 in 3f99541
populate()should only be called iftypeis null.Haarolean commentedon Mar 16, 2024
@bitwiseman got it. How should we solve this taking into consideration the fact that there are multiple fields like this? Should we track the "populated = true/false" flag for an entity or something else?
Haarolean commentedon Jul 25, 2024
@bitwiseman bump?
bitwiseman commentedon Aug 5, 2024
@Haarolean
In this specific case, you can guard the
populate()call withif (type == null).I think some of the classes have a
populate(bool doPopulate)method orpopulate(Object objectToCheckForNullValue)to streamline this process.Tracking
bool isPopulated;as field could also work.I don't like the way we currently don't know what fields we have actually loaded in an instance, but I haven't had time to ponder a better solution for the range partial fields that are returned. Maybe have the base record and then use interfaces to show what fields are present.
What are your thoughts?