Few books page shows error in processing template. UnboundLocalError: local variable 'val' referenced before assignment
https://openlibrary.org/books/OL26079956M/His_Dark_Bond
https://openlibrary.org/books/OL25671368M/Run_to_me_a_novel
https://openlibrary.org/books/OL7574952M/Under_The_Mistletoe
1st Issue
It looks like this is being caused by a KeyError at line 85 here: https://github.com/internetarchive/openlibrary/blob/05b938d95899067457fab3353752fcf031354f21/openlibrary/plugins/openlibrary/stats.py#L81-L88
These links are not throwing an error in dev.
@jamesachamp I would like to solve this issue. Can you please guide me on what changes do I need to make
@Yashs911 Unfortunately, I don't know enough about the middleware to give you good advice about this. You can append ?debug=true to the end of one of the failing URLs to get information about the error:
https://openlibrary.org/books/OL7574952M/Under_The_Mistletoe?debug=true
@jamesachamp I think the word "hit" should be replaced by "key" because it is the only key present in s.data dictionary
@jamesachamp can I create a PR with the proposed changes?
I don't think that is going to fix the issue. 'hit' should always be set whenever the stats.end function is called is openlibrary/core/cache.py:
Also, note that each of the failing entries have a start time (t_start), but are missing an end time (t_end). They also have a time of 0.0, which is the default time set when a stats object is created:
I noticed that each of the entries that are missing an end time have a key value that begins with ia.get_metadata. This may be worth looking into, but it would be good to hear what somebody with more experience with the back-end thinks (@mekarpeles @cdrini).
@Yashs911 I think this issue has been solved on dev.openlibrary.org -- as @jamesachamp suggests:
https://dev.openlibrary.org/books/OL26079956M/His_Dark_Bond?debug=true
We should be able to close this after we do our next deploy (which is blocked by a fix by @cclauss)
@jamesachamp I'm setting you as the lead (if that's okay) -- in the future, when we check the issues we're lead on, can you close this after following up w/ @cclauss next week to confirm the issue is resolved on production after we deploy? Thanks both of you!
@mekarpeles I'm fine with being a lead, but I'm don't think that I have the proper permissions to close issues (or maybe I just need a tutorial :smiley:).
More importantly, is memcache cleared on deployment? If so, testing these URLs after deployment may lead to a false positive.
I can see that each of the pages listed in this issue are now rendering properly, so I'm assuming that this is now resolved.
@cclauss Could you confirm my assumption when you have the time? Thanks so much!