librecores / librecores-web

LibreCores Web Site
https://www.librecores.org/
Other
35 stars 30 forks source link

Better handle GitHub API 404 errors #220

Open imphil opened 6 years ago

imphil commented 6 years ago

See https://sentry.io/librecores/symfony2/issues/488100698/

We get an Github\Exception\RuntimeException in src/Librecores/ProjectRepoBundle/Util/GithubApiService.php in installHook at line 227

In this line we're trying to create a webhook for a repository (API documentation: https://developer.github.com/v3/repos/hooks/#create-a-hook). It's not quite clear where the 404 error comes from, but most likely the user doesn't have permissions to add the webhook (e.g. because it's an org repository).

We should at least catch the error and display a warning to the user (ideally with instructions on how to manually add the webhook), instead of throwing an Exception. Handling the 404 error without a try-catch block should be possible by playing with the HTTP layer used by the GItHub API abstraction, e.g. as described here: https://github.com/KnpLabs/php-github-api/issues/354

@agathver since it was you triggering the exception, do you remember what exactly you did to help reproduce this issue?

recrsn commented 6 years ago

Just opened Add project, couldn't see that dropdown. It threw an error when I was switching to other tabs.

Do we have sentry enabled at the staging?

imphil commented 6 years ago

Yes, sentry is enabled in staging.