Skip to content
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

Do not populate repo list in case of installation:deleted event #1690

Merged
merged 18 commits into from
Mar 14, 2024

Conversation

Haarolean
Copy link
Contributor

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.
image

[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:

  • 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.
  • Add JavaDocs and other comments explaining the behavior.
  • When adding or updating methods that fetch entities, add @link JavaDoc entries to the relevant documentation on https://docs.github.com/en/rest .
  • Add tests that cover any added or changed code. This generally requires capturing snapshot test data. See CONTRIBUTING.md for details.
  • Run mvn -D enable-ci clean install site locally. If this command doesn't succeed, your change will not pass CI.
  • Push your changes to a branch other than main. You will create your PR from that branch.

When creating a PR:

  • Fill in the "Description" above with clear summary of the changes. This includes:
    • If this PR fixes one or more issues, include "Fixes #" lines for each issue.
    • Provide links to relevant documentation on https://docs.github.com/en/rest where possible. If not including links, explain why not.
  • 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."
  • Enable "Allow edits from maintainers".

@bitwiseman
Copy link
Member

bitwiseman commented Aug 15, 2023

@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.

@Haarolean
Copy link
Contributor Author

@bitwiseman I'll try to look into this later this week. Both the suggested approach and a seprate test.

@bitwiseman bitwiseman marked this pull request as draft October 20, 2023 20:56
@Haarolean
Copy link
Contributor Author

@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!

@Haarolean Haarolean marked this pull request as ready for review November 11, 2023 03:57
@bitwiseman bitwiseman self-requested a review November 13, 2023 20:34
@bitwiseman bitwiseman closed this Mar 12, 2024
@bitwiseman bitwiseman reopened this Mar 12, 2024
Copy link

codecov bot commented Mar 14, 2024

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 ⚠️
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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bitwiseman bitwiseman merged commit eb269bd into hub4j:main Mar 14, 2024
11 checks passed
@Haarolean
Copy link
Contributor Author

@bitwiseman thank you!

@Haarolean Haarolean deleted the issues/1689 branch March 15, 2024 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Do not try to populate a repo on Installation:deleted event
2 participants