-
Notifications
You must be signed in to change notification settings - Fork 741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix installation payload handling #1371
Conversation
In the installation payload, the repository doesn't contain a lot of information and it especially does not contain the URL. Tests are passing because we use an offline GitHub instance for testing the payloads.
@@ -2978,7 +2977,7 @@ String getApiTailUrl(String tail) { | |||
if (tail.length() > 0 && !tail.startsWith("/")) { | |||
tail = '/' + tail; | |||
} | |||
return "/repos/" + getOwnerName() + "/" + name + tail; | |||
return "/repos/" + full_name + tail; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, the owner is not provided either in the installation token, the only info we have is the full name.
throw e; | ||
} | ||
} | ||
root().createRequest().withPreview(BAPTISTE).withPreview(NEBULA).withUrlPath(getApiTailUrl("")).fetchInto(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to simplify that but I can add a bunch of ifs if you prefer using the URL coming from the JSON when it is around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is functional and clean. 💯
Codecov Report
@@ Coverage Diff @@
## main #1371 +/- ##
============================================
- Coverage 78.18% 78.10% -0.09%
Complexity 2045 2045
============================================
Files 200 200
Lines 6284 6270 -14
Branches 356 355 -1
============================================
- Hits 4913 4897 -16
- Misses 1162 1165 +3
+ Partials 209 208 -1
Continue to review full report at Codecov.
|
I can confirm that this PR fixes the issue on my GitHub app. 👍 💪 💯 |
@bitwiseman I updated the test to make it a connected one so it's now properly tested. |
@@ -630,7 +630,7 @@ public void checkRunEvent() throws Exception { | |||
GHEventPayload.CheckRun.class); | |||
final GHCheckRun checkRun2 = verifyBasicCheckRunEvent(event2); | |||
|
|||
int expectedRequestCount = mockGitHub.isUseProxy() ? 3 : 2; | |||
int expectedRequestCount = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refreshed the snapshots and this is no longer needed.
Sorry for the slow response. Looking now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Hey @bitwiseman , any chance we could have a release with this fix? Thanks! |
@gsmet Released v1.302 |
@bitwiseman thanks! |
Hey there,
Long time no see :).
The problem was initially reported in my Quarkus GitHub App project: quarkiverse/quarkus-github-app#253.
Parsing
Installation
event payloads with a connectedGitHub
instance (i.e. not an offline one) leads to:Installation payloads do not contain the URL of the repository so we cannot populate the data from there. You can see an example in the tests here:
https://github.com/hub4j/github-api/blob/main/src/test/resources/org/kohsuke/github/GHEventPayloadTest/installation.json#L45-L53
I think what I did is safe but better check the URL thing as I decided to always use a forged URL rather than the one provided in the JSON. I can do it in another way if you prefer and keep the JSON URL when it's provided but, given we already had a try/catch for a corner case, I thought we might as well always forge the URL.
The tests are not failing because we are testing all the payloads with an offline
GitHub
instance thus not populating the repositories. Maybe we should change that? But I'm not totally sure of the consequences of this change. So I thought I might as well ask.Very motivated to get this change in as one of my users is blocked by this so eager to hear your feedback :).