modules.zendframework.com icon indicating copy to clipboard operation
modules.zendframework.com copied to clipboard

Display GitHub error message when module sync fails

Open adamlundrigan opened this issue 9 years ago • 13 comments

Catch the RuntimeException thrown by EdpGithub and send it back to the user.

image

Two notes:

  • I tried to test it but failed. I couldn't find the right incantation to get PHPUnit's mock builder to build a suitable replacement for EdpGithub's RepositoryCollection. Perhaps someone with a kinder disposition towards mock builder could try?
  • I looked through EdpGithub and GitHub's docs and I don't see any case where sensitive information could be leaked through the failure message, so IMO it should be fine to just dump it back to the user for now.

adamlundrigan avatar Jan 27 '15 23:01 adamlundrigan

maybe we move the error catch also to the RepositoryRetreiver class? https://github.com/zendframework/modules.zendframework.com/blob/8af567eaa08f2f67ecf6c0f55998065201ff0cf0/module/Application/test/ApplicationTest/Service/RepositoryRetrieverTest.php#L201 mocked a error case with the github client - helpful?

ins0 avatar Jan 28 '15 00:01 ins0

It's a largely cosmetic change anyway so I didn't put too much effort into writing a test for it...that whole controller is untested and needs a refactor to make that feasible. You're right though, if I mock the client instead of the collection I'd likely have an easier time.

adamlundrigan avatar Jan 28 '15 00:01 adamlundrigan

@adamlundrigan

Not sure about passing through the actual exception message, as you pointed it out, but looks good to me!

localheinz avatar Jan 28 '15 07:01 localheinz

@localheinz thanks for the reivew. I've fixed the items you pointed out.

As for returning the exception message it's not ideal but it's a good stop-gap to keep the spinner from spinning forever if there is a problem with the sync. Ideally EdpGithub or the RepositoryRetriever service would throw distinguishable exceptions (or at least exception messages we know to be safe to send back to the user)

adamlundrigan avatar Jan 28 '15 18:01 adamlundrigan

I'd still ask for a unit test of this functionality (mock with ->throwsException())

Ocramius avatar Jan 28 '15 20:01 Ocramius

@Ocramius I mocked all the things; there are now four test cases covering the changes made in this PR

adamlundrigan avatar Jan 29 '15 02:01 adamlundrigan

@adamlundrigan

Needs a rebase!

localheinz avatar Feb 03 '15 10:02 localheinz

This needs another rebase, sorry for letting it slip through, @adamlundrigan :(

Ocramius avatar Feb 16 '15 00:02 Ocramius

Can this be merged

GeeH avatar Feb 20 '15 14:02 GeeH

Ping @Ocramius @adamlundrigan

GeeH avatar Apr 24 '15 13:04 GeeH

It needs a rebase before it can be merged

Ocramius avatar Apr 27 '15 12:04 Ocramius

                                                                                  I'll take a look today

adamlundrigan avatar Apr 27 '15 13:04 adamlundrigan

The code had changed so much I ditched my original and implemented it fresh, integrating your suggestions:

  • RepositoryRetriever now catches the exception and returns false (@ins0), which is more consistent with the way other methods in RepositoryRetriever behave.
  • indexAction and listAction return 503 when an error is detected (@ocramius)
  • The actual exception message is no longer passed through to the user (@localheinz)
  • Swapped out $.load for $.ajax in the views as the former only handles success conditions.

I was no longer able to reproduce the original API limit exceptions against GitHub (kudos to whomever fixed the sync :+1:) but the principle behind the change is the same: catch any exception coming from EdpGithub and dump out an error message to the user.

adamlundrigan avatar May 01 '15 00:05 adamlundrigan