open-cravat icon indicating copy to clipboard operation
open-cravat copied to clipboard

ModuleInfoCache.update_remote() should be elevate the contents of the HttpError rather than throwing them away

Open tenzinhl opened this issue 3 years ago • 2 comments

Currently store_utils.get_file_to_string() has a catch all except: clause that just returns an empty string when something went wrong with the request. This hid the true nature of the issue when I was running into issues trying to run oc module install-base, which was a simple SSL verification failure due to not having registered the proper certs with the requests library in the docker container.

The interaction that kind of misled me was in admin_util.ModuleInfoCache.update_remote() where all the message says is "please check internet connection", which was not my issue (and for many possible exceptions raised by requests not the issue either).

I would suggest removing the try-catch and just letting any raised exceptions be handled by the calling code. At the very least when it goes unhandled the exception (at least in my case) would have more useful information for debugging the issue.

Understandably this method is called in more than just one spot though, so curious what others' thoughts are on this. I quickly looked for where this function is called and there aren't too many sites.

tenzinhl avatar Aug 10 '22 20:08 tenzinhl

I was originally going to write a PR to make this suggested change, but since I'm a new user to OpenCRAVAT (and thus even greener of a dev) wasn't sure what other side effects it'd have.

tenzinhl avatar Aug 10 '22 20:08 tenzinhl

Hi tenzinhl. Thanks for the detailed digging here. I agree with letting exceptions bubble up from get_file_to_string, and handling them at a higher level. Catching everything into a return "" is icky. I have to read through the code a bit to see what the consequences are though.

If you'd like, we could split this up where you send in a PR that changes get_file_to_string to properly elevate exceptions, and I can fix the calling code.

Open to any suggestions you have.

kmoad avatar Aug 24 '22 16:08 kmoad

Hey! Sorry for the late update. PR is open now: https://github.com/KarchinLab/open-cravat/pull/123

Not many changes there, just has the exception bubble up. Places where the method is called will probably need to be modified for the new contract.

tenzinhl avatar Sep 05 '22 20:09 tenzinhl

Added a couple comments to the pr

kmoad avatar Sep 11 '22 02:09 kmoad

The PR. Along with commits 36e514b6a48ca080e28ebb7e7df6febbb2523378 and d711d154bb0f7632399c3648ad627067b7786ffd should fix this issue. They also improve oc's handling for fatal exceptions.

kmoad avatar Oct 13 '22 21:10 kmoad