github-api
github-api copied to clipboard
Do not populate repo list in case of installation:deleted event
Description
Closes #1689
That's a proposition of a solution I came up with.
Unfortunately I haven't been able to run the whole test suite due to the same repeating exception occurring and I didn't have time to look into that.
[ERROR] Tests run: 66, Failures: 0, Errors: 5, Skipped: 11, Time elapsed: 2.251 s <<< FAILURE! - in org.kohsuke.github.AppTest
[ERROR] testCreateIssue(org.kohsuke.github.AppTest) Time elapsed: 0.026 s <<< ERROR!
org.kohsuke.github.GHIOException: Failed to set the custom verb
at org.kohsuke.github.internal.GitHubConnectorHttpConnectorAdapter.send(GitHubConnectorHttpConnectorAdapter.java:82)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:432)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:403)
at org.kohsuke.github.Requester.send(Requester.java:70)
at org.kohsuke.github.GHIssue.edit(GHIssue.java:273)
at org.kohsuke.github.GHIssue.close(GHIssue.java:294)
at org.kohsuke.github.AppTest.testCreateIssue(AppTest.java:274)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.kohsuke.github.junit.WireMockMultiServerRule$1.evaluate(WireMockMultiServerRule.java:113)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Caused by: java.io.IOException: Failed to set the custom verb
at org.kohsuke.github.internal.GitHubConnectorHttpConnectorAdapter.setRequestMethod(GitHubConnectorHttpConnectorAdapter.java:129)
at org.kohsuke.github.internal.GitHubConnectorHttpConnectorAdapter.setupConnection(GitHubConnectorHttpConnectorAdapter.java:97)
at org.kohsuke.github.internal.GitHubConnectorHttpConnectorAdapter.send(GitHubConnectorHttpConnectorAdapter.java:79)
... 35 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.String java.net.HttpURLConnection.method accessible: module java.base does not "opens java.net" to unnamed module @2c8b1039
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:180)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:174)
at org.kohsuke.github.internal.GitHubConnectorHttpConnectorAdapter.setRequestMethod(GitHubConnectorHttpConnectorAdapter.java:126)
... 37 more
Before submitting a PR:
- [x] Changes must not break binary backwards compatibility. If you are unclear on how to make the change you think is needed while maintaining backward compatibility, CONTRIBUTING.md for details.
- [x] Add JavaDocs and other comments explaining the behavior.
- [x] When adding or updating methods that fetch entities, add
@linkJavaDoc entries to the relevant documentation on https://docs.github.com/en/rest . - [x] Add tests that cover any added or changed code. This generally requires capturing snapshot test data. See CONTRIBUTING.md for details.
- [x] Run
mvn -D enable-ci clean install sitelocally. If this command doesn't succeed, your change will not pass CI. - [x] Push your changes to a branch other than
main. You will create your PR from that branch.
When creating a PR:
- [x] Fill in the "Description" above with clear summary of the changes. This includes:
- [x] If this PR fixes one or more issues, include "Fixes #
" lines for each issue. - [x] Provide links to relevant documentation on https://docs.github.com/en/rest where possible. If not including links, explain why not.
- [x] If this PR fixes one or more issues, include "Fixes #
- [x] All lines of new code should be covered by tests as reported by code coverage. Any lines that are not covered must have PR comments explaining why they cannot be covered. For example, "Reaching this particular exception is hard and is not a particular common scenario."
- [x] Enable "Allow edits from maintainers".
@Haarolean Sorry for the slow response. Thank you for working on this.
Looking at this - https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#installation
Maybe the right solution here is to change the event to have private List<GHInstallation.Repository> repositories;, add a static class called GHInstallation.Repository that has only the fields listed under Properties of repositories in the docs., and add a method public List<GHInstallation.Repository> getRawRepositories(). Then, make the getRepositories() method only load it's list of repositories the first time it is called (and have it throw a meaningful error message when the action is deleted).
Either way we'll need an additional test for the installation that covers created since deleted is going to be a special case. Tell me if you want help setting up the test.
@bitwiseman I'll try to look into this later this week. Both the suggested approach and a seprate test.
@bitwiseman I think I've done what we've discussed above. I've used a real recent webhook payload, but replaced a repo within it with the one we already have captured data for, I don't think that's critical to capture a snapshot here for just that. Let me know what you think!
Codecov Report
Attention: Patch coverage is 89.47368% with 2 lines in your changes are missing coverage. Please review.
Project coverage is 80.73%. Comparing base (
1aa7178) to head (acc027f). Report is 2 commits behind head on main.
| Files | Patch % | Lines |
|---|---|---|
| ...c/main/java/org/kohsuke/github/GHEventPayload.java | 89.47% | 2 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #1690 +/- ##
============================================
+ Coverage 80.66% 80.73% +0.06%
Complexity 2342 2342
============================================
Files 220 220
Lines 7082 7096 +14
Branches 379 379
============================================
+ Hits 5713 5729 +16
Misses 1132 1132
+ Partials 237 235 -2
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@bitwiseman thank you!