Openlibrary: Few books webpage shows error in processing template

Created on 14 Oct 2020  路  10Comments  路  Source: internetarchive/openlibrary

Few books page shows error in processing template. UnboundLocalError: local variable 'val' referenced before assignment

Evidence / Screenshot (if possible)

erroropenlibrary

Relevant url?

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

Steps to Reproduce

  1. Go to https://openlibrary.org/
  2. Click on His_Dark_Bond/Run_to_me_a_novel/Under_The_Mistletoe

  • Actual: Error in processing template
  • Expected: New Page

Details

  • Logged in (Y/N)? N
  • Browser type/version? Google Chrome
  • Operating system? Windows 10
  • Environment (prod/dev/local)? prod

Stakeholders

1st Issue

Not an Issue @jamesachamp 2 Bug

All 10 comments

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

sol

@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:

https://github.com/internetarchive/openlibrary/blob/3b34cf8b71d15f61e51da0e83382688bd1a7c37c/openlibrary/core/cache.py#L311-L316

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:

https://github.com/internetarchive/infogami/blob/1e8a391d6a60ece491cbcf1f87db5cd265b888cb/infogami/utils/stats.py#L23-L33

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jdlrobson picture jdlrobson  路  5Comments

cdrini picture cdrini  路  4Comments

bitnapper picture bitnapper  路  4Comments

nonom picture nonom  路  3Comments

LeadSongDog picture LeadSongDog  路  5Comments