Skip to content

Only HTTPError has a code attribute

Laurent Bachelier requested to merge laurentbachelier/irker:master into master

This would crash in case we get a URLError instead of HTTPError, for example.

This was reported on IRC and apparently fixes the user's problem, I didn't reproduce it myself.

1726 nn2> hi. might have found a small bug while trying out irker. 1726 nn2> short version: AttributeError exception on git push when irker.urlprefix is not set to None and no cgit/... is available. 1727 nn2> irker 2.17 running on xubuntu 16.04.1 live inside a vm, as well as a bare git repos with default irkerhook-git and an irc daemon inside the vm 1728 nn2> on push i get a python backtrace ending in "... line 99 in __unicode__\n if e.code == 401:\n AttributeError: 'URLError' object has no attribute 'code'" 1729 nn2> i suppose irkerhook probes a cgit installation, which does not exist, thus an IOError is thrown, which does not have a "code" attribute (cf. the python docs: should this have been HTTPError?) 1730 nn2> (when i add urlprefix = None to the repos config, the notification works (no exception), as expected since that's caught earlier) 1734 laurentb> so you have urlprefix set, but it's empty? 1735 laurentb> actually it should default to gitweb, nevermind 1736 nn2> no i didn't set it 1738 nn2> the only [irker] settings in the git repos' config are project = test and channels = irc://localhost/test 1741 laurentb> potential fix: https://gitlab.com/laurentbachelier/irker/commit/dc52cddb14db5406a8a6fe1b4890acfaf1990a9b 1741 laurentb> I didn't test it myself 1753 nn2> tested with irkerhook/irkerd from git master and the post-receive script from the debian package - same exception 1754 drnlm> laurentb: the indentation after the IOError check looks weird, but otherwise that change looks sensible to me 1754 nn2> tested with laurentb/master and the same post-receive script: works (irc notification sent and no exception thrown) 1755 laurentb> indeed, I fixed the identation 1755 laurentb> cool 1758 nn2> :) (please keep in mind that i'm new to irker and thus might have missed something) 1759 laurentb> in any case the error shouldn't happen, though I'm not sure *why* it happens 1801 laurentb> i.e. I don't think an url should get probed at all in your case, but somehow it happens

Merge request reports