handleGitHubInstallation doesn't handle empty repositories
See original GitHub issueSaw this error pop up a couple of times today on prod:
io.dockstore.webservice.resources.WorkflowResource: GitHub app installed on the repositories (agduncan94)
! java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
! at io.dockstore.webservice.resources.WorkflowResource.lambda$handleGitHubInstallation$22(WorkflowResource.java:2028)
...
"POST /workflows/github/install HTTP/1.0" 500 110 "-" "-" 3
ArrayIndexOutOfBoundsException
is thrown at https://github.com/dockstore/dockstore/blob/1.9.1/dockstore-webservice/src/main/java/io/dockstore/webservice/resources/WorkflowResource.java#L2028 indicating the repository string didn’t contain a /
.
The io.dockstore.webservice.resources.WorkflowResource: GitHub app installed on the repositories (agduncan94)
resulting from https://github.com/dockstore/dockstore/blob/1.9.1/dockstore-webservice/src/main/java/io/dockstore/webservice/resources/WorkflowResource.java#L2022 leads us to believe that repositories
was empty (thanks @garyluu ).
Additional context
- Webservice version: 1.9.1
- host location: dockstore.org
┆Issue is synchronized with this Jira Story ┆Issue Number: DOCK-1556 ┆Sprint: Sprint 47- Vampire Squid ┆Issue Type: Story
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
Summary of what is happening. We do not distinguish between installation_repositories events for adding or removing installations. The action key in the GitHub event can be used to determine if it is an install or uninstall (added and removed respectively).
The uninstall/remove action is calling the installation endpoint on the dockstore webservice with the following information installationId=xxxxxxx&username=agduncan94&repositories=
Note the empty repositories string. This is because we were looking at the repositories_added field of the GitHub event. For uninstall events, there is a repositories_removed field.
There are two solutions I can think of
We don’t care about uninstall events. Check in the lambda that installation_repositories events have the “added” action. If so, then call the endpoint, else don’t do anything. This might be a good quick fix to prevent the 500 errors we keep seeing.
We care about install events. The lambda must pass along the action “added” or “removed” to the endpoint (workflows/github/install) on our web service. It must also find the list of repositories from the correct location (either repositories_added or repositories_removed). The endpoint on our web service will be updated to keep track of both action types. Might need to create a new event ENUM for uninstall.
See https://developer.github.com/webhooks/event-payloads/#installation_repositories for more information.
@GFJHogue This is deployed to dev